Golang 脚手架,Go 简单,Go 直接
// 配置
cp .env.example .env
// 日志
mkdir runtime
// 构建
go build main.go
// 构建时指定 CPU 核心数量
go build -ldflags "-X main.SetCpuCount=1" main.go
// 获取运行参数
./main server -h
// 开启接口服务
./main server
// 运行脚本
./main cmd demo hello
./main cmd demo world
- 依赖
go get -u github.com/swaggo/swag/cmd/[email protected]
go get -u github.com/swaggo/[email protected]
go get -u github.com/swaggo/files
go get -u github.com/alecthomas/template
- 初始化
swag init
- 访问
https://127.0.0.1:9551/swagger/index.html
go get github.com/smartystreets/goconvey
cd test/redis
go test -v
cd test/curl
goconvey
Role | Package | Link |
---|---|---|
命令 | cobra | https://github.com/spf13/cobra |
路由 | Gin | https://github.com/gin-gonic/gin |
配置 | godotenv | https://github.com/joho/godotenv |
ORM | Gorm | https://github.com/go-gorm/gorm |
redis | redigo | https://github.com/gomodule/redigo |
Curl | goz | https://github.com/idoubi/goz |
Json | gjson | https://github.com/tidwall/gjson |
日志 | logrus | https://github.com/sirupsen/logrus |
鉴权 | jwt-go | https://github.com/golang-jwt/jwt |
文档 | gin-swagger | https://github.com/swaggo/gin-swagger |
测试 | goconvey | https://github.com/smartystreets/goconvey |
Kafka | kafka-go | https://github.com/segmentio/kafka-go |
RabbitMq | amqp | https://github.com/streadway/amqp |
Etcd | etcd | https://github.com/coreos/etcd/clientv3 |