feat: 添加微服务模板基础架构

- 创建基于 CloudWego Hertz 的 Go 微服务脚手架
- 集成 Nacos 服务注册/发现功能
- 添加 gRPC 客户端支持
- 实现环境变量配置管理 (.env.example)
- 添加 HTTP 中间件 (Recovery, AccessLog, CORS)
- 配置 Gitea CI/CD 构建部署流程

BREAKING CHANGE: 项目结构调整,从简单的 API 服务升级为完整的微服务架构
This commit is contained in:
shiran
2026-04-15 11:13:38 +08:00
parent 8654cd6e5c
commit 6050d11f27
30 changed files with 1643 additions and 358 deletions
+20 -6
View File
@@ -1,19 +1,33 @@
package main
import (
"apiServer_service/utils/httplog"
"apiServer_service/utils/logger"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/joho/godotenv"
"log"
)
func init() {
// 在 init 中加载 .env 文件
err := godotenv.Load(".env")
if err != nil {
log.Fatal("Error loading .env file")
if err := godotenv.Load(".env"); err != nil {
fmt.Println("Warning: .env file not found, using system environment variables")
}
}
func main() {
fmt.Println("子应用 main 方法")
redisKey := os.Getenv("ES_REDIS_KEY")
esIndexPrefix := os.Getenv("ES_INDEX_PREFIX")
logger.Info("CLI", fmt.Sprintf("httplog 上报启动 (redis_key=%s, es_index=%s-*)", redisKey, esIndexPrefix))
go httplog.Updater(redisKey, esIndexPrefix)
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
logger.Info("CLI", "正在关闭...")
}