gofr-dev/gofr
GitHub: gofr-dev/gofr
GoFr 是一个为加速微服务开发而设计的 Go 语言框架,内置数据库支持和可观测性能力。
Stars: 17446 | Forks: 1740
## 🎯 **目标**
GoFr 旨在**简化微服务开发**,重点关注 **Kubernetes 部署**和**开箱即用的可观测性**。虽然它能够构建通用应用程序,但**微服务**始终是其核心。
## 💡 **核心功能**
1. **简洁的 API 语法**
2. **默认遵循 REST 标准**
3. **配置管理**
4. **[可观测性](https://gofr.dev/docs/quick-start/observability)**(日志、链路追踪、指标)
5. **内置 [Auth 中间件](https://gofr.dev/docs/advanced-guide/http-authentication)** 与自定义中间件支持
6. **[gRPC 支持](https://gofr.dev/docs/advanced-guide/grpc)**
7. **支持熔断器的 [HTTP 服务](https://gofr.dev/docs/advanced-guide/http-communication)**
8. **[Pub/Sub](https://gofr.dev/docs/advanced-guide/using-publisher-subscriber)**
9. 针对所有数据源的 **[健康检查](https://gofr.dev/docs/advanced-guide/monitoring-service-health)**
10. **[数据库迁移](https://gofr.dev/docs/advanced-guide/handling-data-migrations)**
11. **[定时任务](https://gofr.dev/docs/advanced-guide/using-cron)**
12. **支持无需重启[更改日志级别](https://gofr.dev/docs/advanced-guide/remote-log-level-change)**
13. **[Swagger 渲染](https://gofr.dev/docs/advanced-guide/swagger-documentation)**
14. **[抽象文件系统](https://gofr.dev/docs/advanced-guide/handling-file)**
15. **[Websockets](https://gofr.dev/docs/advanced-guide/websocket)**
## 🚀 **快速入门**
### **前置条件**
- GoFr 需要 **[Go](https://go.dev/)** 版本 **[1.24](https://go.dev/doc/devel/release#go1.24.0)** 或更高版本。
### **安装**
要开始使用 GoFr,请将以下 import 添加到您的代码中,并使用 Go 的模块支持自动获取依赖项:
```
import "gofr.dev/pkg/gofr"
```
或者,使用以下命令:
```
go get -u gofr.dev/pkg/gofr
```
## 🏃 **运行 GoFr**
以下是一个启动并运行 GoFr 应用程序的简单示例:
```
package main
import "gofr.dev/pkg/gofr"
func main() {
app := gofr.New()
app.GET("/greet", func(ctx *gofr.Context) (any, error) {
return "Hello World!", nil
})
app.Run() // listens and serves on localhost:8000
}
```
运行此代码:
```
$ go run main.go
```
访问 [`localhost:8000/greet`](http://localhost:8000/greet) 查看结果。
## 📂 **更多示例**
在 [GoFr 示例目录](https://github.com/gofr-dev/gofr/tree/development/examples)中探索各种可直接运行的示例。
## 👩💻 **文档**
- **[GoDoc](https://pkg.go.dev/gofr.dev)**:官方 API 文档。
- **[GoFr 文档](https://gofr.dev/docs)**:详尽的指南和资源。
## 🔒 **安全克隆**
要安全地克隆 GoFr 仓库,您可以使用 HTTPS 或 SSH:
### 使用 HTTPS 克隆
```
git clone https://github.com/gofr-dev/gofr.git
```
### 使用 SSH 克隆
```
git clone git@github.com:gofr-dev/gofr.git
```
### 🎁 **获取 GoFr T 恤与贴纸!**
如果您的 PR 被合并,或者您通过撰写文章或推广 GoFr 做出了贡献,我们邀请您填写[此表单](https://forms.gle/R1Yz7ZzY3U5WWTgy5)以领取您的 GoFr 周边产品,作为我们要表达感谢的心意!
### 合作伙伴
标签:API开发, API集成, CNCF, GoFr, Go语言, Python工具, RESTful, Web框架, web渗透, 中间件, 企业级开发, 可观测性, 后端开发, 子域名突变, 开源框架, 微服务架构, 微服务框架, 快速开发, 持续集成, 搜索引擎查询, 数据库支持, 日志审计, 服务端, 测试用例, 程序破解, 高并发