{"id":28758865,"url":"https://github.com/uptutu/doghole","last_synced_at":"2025-06-17T04:39:55.152Z","repository":{"id":298622639,"uuid":"999928635","full_name":"uptutu/doghole","owner":"uptutu","description":"My App Server Skeleton. Build with fiber\\ent\\zap.","archived":false,"fork":false,"pushed_at":"2025-06-12T02:04:20.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-12T03:24:14.705Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uptutu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-11T02:34:08.000Z","updated_at":"2025-06-12T02:04:23.000Z","dependencies_parsed_at":"2025-06-12T03:34:30.138Z","dependency_job_id":null,"html_url":"https://github.com/uptutu/doghole","commit_stats":null,"previous_names":["uptutu/doghole"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/uptutu/doghole","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptutu%2Fdoghole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptutu%2Fdoghole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptutu%2Fdoghole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptutu%2Fdoghole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uptutu","download_url":"https://codeload.github.com/uptutu/doghole/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptutu%2Fdoghole/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260294191,"owners_count":22987600,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-17T04:39:51.660Z","updated_at":"2025-06-17T04:39:55.140Z","avatar_url":"https://github.com/uptutu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doghole\n\nMy App Server Skeleton. Build with fiber\\ent\\zap.\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/uptutu/doghole)](https://goreportcard.com/report/github.com/uptutu/doghole)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/uptutu/doghole)](https://golang.org/)\n[![License](https://img.shields.io/github/license/uptutu/doghole)](LICENSE)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/uptutu/doghole/go.yml?branch=main)](https://github.com/uptutu/doghole/actions)\n\n**Doghole** 是一个使用 Go 语言编写的现代化、高性能的 Web 应用程序骨架。它集成了以下优秀的技术栈：\n\n- **Fiber**: 一个受 Express.js 启发的 Go Web 框架，以高性能和低内存占用著称。\n- **Ent**: 一个简单而强大的 Go 实体框架，用于轻松管理数据库模式和查询。\n- **Zap**: 一个极快、结构化的 Go 日志库。\n- **Cobra**: 一个强大的 Go CLI 应用程序库。\n- **Viper**: 一个完整的 Go 应用程序配置解决方案。\n\n## ✨ 特性\n\n- **模块化设计**: 清晰的项目结构，易于扩展和维护。\n- **配置驱动**: 通过 YAML 文件或环境变量轻松配置应用程序。\n- **结构化日志**: 使用 Zap 实现高性能的结构化日志记录。\n- **数据库集成**: 使用 Ent 进行类型安全的数据库操作和迁移。\n- **CLI 支持**: 使用 Cobra 构建强大的命令行界面。\n- **优雅关闭**: 服务器支持优雅关闭，确保请求处理完成。\n- **API 版本控制**: 内置 API 版本控制机制。\n- **中间件支持**: 易于添加和管理中间件（如 CORS、Logger、RequestID）。\n- **Makefile 支持**: 包含一个 Makefile，用于简化构建、运行、测试和清理任务。\n- **版本信息注入**: 构建时自动注入版本号、Git Commit Hash 和构建时间。\n\n## 🚀 快速开始\n\n### 先决条件\n\n- [Go](https://golang.org/dl/) (版本 1.20 或更高)\n- [Docker](https://www.docker.com/get-started) (可选, 用于数据库)\n- [Make](https://www.gnu.org/software/make/) (用于执行 Makefile 命令)\n\n### 安装\n\n1.  **克隆仓库**:\n    ```bash\n    git clone https://github.com/your_username/doghole.git\n    cd doghole\n    ```\n\n2.  **安装依赖**:\n    ```bash\n    go mod tidy\n    ```\n\n### 配置\n\n1.  复制示例配置文件:\n    ```bash\n    cp config.example.yaml config.yaml\n    ```\n2.  根据您的环境修改 `config.yaml` 文件，特别是数据库连接信息。\n\n### 运行\n\n有多种方式可以运行此应用程序：\n\n1.  **使用 `go run` (开发模式)**:\n    ```bash\n    go run main.go server --config config.yaml\n    ```\n\n2.  **使用 `make run` (推荐的开发模式)**:\n    ```bash\n    make run\n    ```\n\n3.  **构建并运行二进制文件**:\n    ```bash\n    make build\n    ./doghole server --config config.yaml\n    ```\n\n服务器默认启动在 `http://localhost:8080`。\n\n## 🛠️ Makefile 命令\n\n项目包含一个 `Makefile` 来简化常见的开发任务：\n\n-   `make build`: 构建应用程序二进制文件。\n-   `make run`: 在开发模式下运行应用程序。\n-   `make clean`: 清理构建产物。\n-   `make test`: 运行单元测试。\n-   `make lint`: 运行 Go linter (需要安装 `golangci-lint`)。\n-   `make help`: 显示所有可用的 Makefile 命令。\n\n## 📦 构建\n\n要构建生产环境的二进制文件，包含版本信息：\n\n```bash\nmake build\n```\n\n这将生成一个名为 `doghole` (或您在 Makefile 中配置的名称) 的可执行文件。\n\n## 📝 版本控制\n\n应用程序支持在构建时注入版本信息。您可以通过以下命令查看版本：\n\n```bash\n./doghole version\n```\n\n或者，如果您正在运行服务，通常会有一个 `/version` 或类似的管理端点来显示此信息。\n\n## ⚙️ 配置选项\n\n应用程序可以通过 `config.yaml` 文件或环境变量进行配置。详细的配置选项请参考 `config/config.go` 文件中的结构体定义。\n\n主要配置部分包括：\n\n-   `server`: HTTP 服务器配置 (端口、超时等)\n-   `db`: 数据库连接配置 (支持主从库)\n-   `logger`: 日志系统配置 (级别、格式、输出等)\n\n## 🤝 贡献\n\n欢迎贡献！如果您想为 Doghole 做出贡献，请遵循以下步骤：\n\n1.  Fork 本仓库。\n2.  创建一个新的分支 (`git checkout -b feature/your-feature-name`)。\n3.  提交您的更改 (`git commit -am 'Add some feature'`)。\n4.  将您的分支推送到远程仓库 (`git push origin feature/your-feature-name`)。\n5.  创建一个新的 Pull Request。\n\n请确保您的代码符合项目编码规范，并通过所有测试。\n\n## 📄 许可证\n\n本项目采用 [MIT 许可证](LICENSE)。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuptutu%2Fdoghole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuptutu%2Fdoghole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuptutu%2Fdoghole/lists"}