本模板基于 SiiWay Go 代码规范,目标是统一开发流程与质量门槛。
.
├── cmd/
│ └── server/
│ └── main.go
├── internal/
│ ├── app/
│ │ └── server.go
│ ├── handler/
│ │ └── health_handler.go
│ └── service/
│ ├── health_service.go
│ └── health_service_test.go
├── .golangci.yml
├── .gitignore
├── go.mod
├── lefthook.yml
└── Makefile
go run ./cmd/server
curl http://localhost:8080/healthzmake fmt
make lint
make test
make vuln
make checkgofmt -w .
gofumpt -w .
gci write .
golangci-lint run ./...
go test ./...
govulncheck ./...- 包名使用简短小写单词。
- 文件名使用小写加下划线。
- 导出符号使用 PascalCase,非导出符号使用 camelCase。
context.Context放在参数第一位。- 错误必须显式处理,并使用
%w包装上下文。