基于 [Sniper] 轻量级业务框架 (https://github.com/go-kiss/sniper) 生成的Gaea Layout.
- 类 UNIX 系统
- go v1.12+
- protoc
- protoc-gen-go
├── cmd # 服务子命令
├── dao # 数据访问层
├── main.go # 项目总入口
├── rpc # 接口描述文件
├── server # 控制器层
├── service # 业务逻辑层
├── sniper.toml # 配置文件
└── util # 业务工具库
go build ./cmd/sniper
# 首次使用需要安装 protoc-gen-twirp 工具
make cmd
./sniper rename --package moocss.com/gaea
go run cmd/sniper/main.go rpc --server auth --service user
# 针对指定服务
protoc --go_out=. --twirp_out=. echo.proto
find rpc -name '*.proto' -exec protoc --twirp_out=. --go_out=. {} ;
make rpc
### 测试
```bash
curl --request "POST" \
--header "Content-Type: application/json" \
--data '{"msg": "Hello World"}' \
http://localhost:8080/api/helloworld.v1.Helloworld/Echo
echo 'msg:"Hello World"' \
| protoc --encode helloworld.v1.HelloworldEchoReq ./rpc/example/v1/helloworld.proto \
| curl -s --request POST \
--header "Content-Type: application/protobuf" \
--data-binary @- \
http://localhost:8080/api/helloworld.v1.Helloworld/Echo \
| protoc --decode helloworld.v1.HelloworldEchoResp ./rpc/example/v1/helloworld.proto
grep -rl "检索内容" --include="*" ./ | xargs sed -i "" "s/检索内容/修改后内容/g"
redis-server # 启动redis服务端
redis-cli # 启动redis客户端
shutdown # 关闭redis服务端