{"id":302,"date":"2026-09-27T01:08:13","date_gmt":"2026-09-26T17:08:13","guid":{"rendered":"https:\/\/xiit.cn\/?p=302"},"modified":"2026-09-27T01:08:13","modified_gmt":"2026-09-26T17:08:13","slug":"go%e9%a1%b9%e7%9b%ae%e6%9e%b6%e6%9e%84%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"https:\/\/xiit.cn\/index.php\/2026\/09\/27\/go%e9%a1%b9%e7%9b%ae%e6%9e%b6%e6%9e%84%e8%ae%be%e8%ae%a1\/","title":{"rendered":"Go\u9879\u76ee\u67b6\u6784\u8bbe\u8ba1"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u9879\u76ee\/<br>\u251c\u2500\u2500 .github\/<br>\u2502 \u2514\u2500\u2500 workflows\/ # CI\/CD \u81ea\u52a8\u5316\u6d41\u6c34\u7ebf\u914d\u7f6e<br>\u251c\u2500\u2500 api\/<br>\u2502 \u2514\u2500\u2500 v1\/ # OpenAPI \u89c4\u8303\u3001Protobuf \u7b49\u63a5\u53e3\u5951\u7ea6\u5b9a\u4e49<br>\u251c\u2500\u2500 cmd\/<br>\u2502 \u251c\u2500\u2500 cron\/ # \u72ec\u7acb\u5165\u53e3\uff1a\u5b9a\u65f6\u4efb\u52a1\/\u8dd1\u6279\u7a0b\u5e8f<br>\u2502 \u2502 \u2514\u2500\u2500 main.go<br>\u2502 \u2514\u2500\u2500 server\/ # \u72ec\u7acb\u5165\u53e3\uff1a\u4e3b\u670d\u52a1 (API &amp; Bot)<br>\u2502 \u251c\u2500\u2500 main.go # \u7eaf\u51c0\u7684\u542f\u52a8\u51fd\u6570<br>\u2502 \u2514\u2500\u2500 wire.go # (\u53ef\u9009) Google Wire \u4f9d\u8d56\u6ce8\u5165\u914d\u7f6e<br>\u251c\u2500\u2500 configs\/<br>\u2502 \u251c\u2500\u2500 loader\/ # \u914d\u7f6e\u52a0\u8f7d\u5668 (\u5c01\u88c5 Viper\uff0c\u652f\u6301 Env\/YAML \u8bfb\u53d6)<br>\u2502 \u251c\u2500\u2500 config.go # \u5f3a\u7c7b\u578b\u7684\u5168\u5c40\u914d\u7f6e\u7ed3\u6784\u4f53\u5b9a\u4e49<br>\u2502 \u2514\u2500\u2500 config.example.yaml # \u914d\u7f6e\u6587\u4ef6\u6a21\u677f (\u5f00\u53d1\u73af\u5883\u4f7f\u7528)<br>\u251c\u2500\u2500 deployments\/<br>\u2502 \u251c\u2500\u2500 docker-compose.yml # \u672c\u5730\/\u6d4b\u8bd5\u73af\u5883\u7684\u5bb9\u5668\u7f16\u6392<br>\u2502 \u2514\u2500\u2500 Dockerfile # \u751f\u4ea7\u73af\u5883\u7684\u591a\u9636\u6bb5\u6784\u5efa\u914d\u7f6e<br>\u251c\u2500\u2500 docs\/<br>\u2502 \u251c\u2500\u2500 api\/ # Swagger \u7b49 API \u8bf4\u660e\u6587\u6863<br>\u2502 \u2514\u2500\u2500 development\/ # \u56e2\u961f\u5f00\u53d1\u6307\u5357\u3001\u73af\u5883\u642d\u5efa\u6587\u6863<br>\u251c\u2500\u2500 internal\/ # \ud83c\udf1f \u6838\u5fc3\u4e1a\u52a1\u5c42 (\u5916\u90e8\u9879\u76ee\u4e0d\u53ef\u89c1)<br>\u2502 \u251c\u2500\u2500 bot\/ # Telegram \u673a\u5668\u4eba\u4ea4\u4e92\u3001\u4e8b\u4ef6\u76d1\u542c\u4e0e\u5206\u53d1<br>\u2502 \u251c\u2500\u2500 domain\/ # \u6838\u5fc3\u4e1a\u52a1\u5b9e\u4f53 (Entity)\u3001\u901a\u7528\u6570\u636e\u7ed3\u6784\u5b9a\u4e49<br>\u2502 \u251c\u2500\u2500 handler\/ # HTTP \u8bf7\u6c42\u5904\u7406\u5c42 (Controller)<br>\u2502 \u251c\u2500\u2500 metrics\/ # \u53ef\u89c2\u6d4b\u6027\uff1aPrometheus \u76d1\u63a7\u6307\u6807\u4e0e Tracing<br>\u2502 \u251c\u2500\u2500 middleware\/ # \u62e6\u622a\u5668\uff1aAuth(\u9274\u6743), CORS(\u8de8\u57df), I18n(\u591a\u8bed\u8a00)<br>\u2502 \u251c\u2500\u2500 repository\/ # \u6570\u636e\u8bbf\u95ee\u5c42\uff1aMySQL\/Redis\/MongoDB \u5404\u79cd\u5177\u4f53\u64cd\u4f5c<br>\u2502 \u251c\u2500\u2500 service\/ # \u6838\u5fc3\u4e1a\u52a1\u903b\u8f91\u5c42 (\u534f\u8c03 Repository \u548c Bot)<br>\u2502 \u2514\u2500\u2500 pkg\/ # \ud83d\udd27 \u5185\u90e8\u5171\u4eab\u7ec4\u4ef6<br>\u2502 \u251c\u2500\u2500 errors\/ # \u7edf\u4e00\u4e1a\u52a1\u9519\u8bef\u7801\u4e0e\u9519\u8bef\u5904\u7406\u5b9a\u4e49<br>\u2502 \u251c\u2500\u2500 i18n\/ # \u56fd\u9645\u5316\u89e3\u6790\u5f15\u64ce<br>\u2502 \u251c\u2500\u2500 logger\/ # \u65e5\u5fd7\u5e93\u5c01\u88c5 (Zap\/Slog)<br>\u2502 \u251c\u2500\u2500 response\/ # \u7edf\u4e00 JSON \u8f93\u51fa\u5c01\u88c5 (Success\/Error\/Page)<br>\u2502 \u2514\u2500\u2500 validator\/ # \u53c2\u6570\u6821\u9a8c\u5668\u5c01\u88c5<br>\u251c\u2500\u2500 locales\/<br>\u2502 \u251c\u2500\u2500 en-US.yaml # \u82f1\u6587\u7ffb\u8bd1\u6587\u672c<br>\u2502 \u2514\u2500\u2500 zh-CN.yaml # \u4e2d\u6587\u7ffb\u8bd1\u6587\u672c<br>\u251c\u2500\u2500 migrations\/ # \u6570\u636e\u5e93 Schema \u7248\u672c\u8fc1\u79fb\u811a\u672c (00001_init.up.sql)<br>\u251c\u2500\u2500 pkg\/ # (\u9884\u7559) \u786e\u8ba4\u53ef\u4ee5\u5f00\u6e90\u6216\u7ed9\u5176\u4ed6\u9879\u76ee\u5f15\u7528\u7684\u5e95\u5c42\u901a\u7528\u5e93<br>\u251c\u2500\u2500 third_party\/ # \u5916\u90e8\u7b2c\u4e09\u65b9\u8d44\u6e90 (\u5982 Swagger UI \u9759\u6001\u6587\u4ef6)<br>\u251c\u2500\u2500 .editorconfig # \u7edf\u4e00\u56e2\u961f\u7f16\u8f91\u5668\u683c\u5f0f\u89c4\u8303<br>\u251c\u2500\u2500 .gitignore # Git \u5ffd\u7565\u6587\u4ef6\u914d\u7f6e<br>\u251c\u2500\u2500 .golangci.yml # \u4ee3\u7801\u9759\u6001\u68c0\u67e5\u5668\u914d\u7f6e<br>\u251c\u2500\u2500 Makefile # \u5feb\u6377\u6307\u4ee4\u96c6 (make run, make build, make lint)<br>\u251c\u2500\u2500 go.mod # \u6a21\u5757\u4f9d\u8d56\u7ba1\u7406<br>\u251c\u2500\u2500 go.sum<br>\u2514\u2500\u2500 README.md # \u9879\u76ee\u6982\u89c8\u4e0e\u5feb\u901f\u542f\u52a8\u8bf4\u660e<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9879\u76ee\/\u251c\u2500\u2500 .github\/\u2502 \u2514\u2500\u2500 workflows\/ # CI\/CD \u81ea\u52a8\u5316\u6d41\u6c34\u7ebf\u914d\u7f6e\u251c\u2500\u2500 api [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-golang"],"_links":{"self":[{"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":1,"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":303,"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/posts\/302\/revisions\/303"}],"wp:attachment":[{"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xiit.cn\/index.php\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}