export GOPROXY=https://goproxy.io
# 注意该梯子不支持私有repo,私有repo请去掉GOPROXY
export GOPROXY=
go >= 1.11(由于使用了 go mod 管理版本依赖)
export GO111MODULE=on
// 1. 获取 yago
go get github.com/hulklab/yago/yago
// 2. 用 yago 在当前目录创建你的项目 myapp
yago init -a myapp
// 3. 进入目录初始化
cd myapp/
go mod init
// 4. build
go build
// 5. 启动
./myapp -c conf/app.toml
// 5.1. 创建属于自己的配置文件,并启动
sh env.init.sh yourname
./myapp
// 6. 控制是否需要在此机器上开启 task 任务,有两种方式
// 修改配置文件中的 app.task_enable,默认为开启
// 修改环境变量 export {{配置文件中的app_name}}_APP_TASK_ENABLE=1, 1 表示开启,0 表示关闭,配置文件与环境变量同时存在时环境变量生效
├── app
│ ├── g
│ │ └── errors.go
│ ├── modules
│ │ └── home
│ │ ├── homecmd
│ │ │ └── home.go
│ │ ├── homedao
│ │ │ └── home.go
│ │ ├── homehttp
│ │ │ └── home.go
│ │ ├── homemodel
│ │ │ └── home.go
│ │ ├── homerpc
│ │ │ ├── home.go
│ │ │ ├── home_test.go
│ │ │ │ └── homepb
│ │ │ │ ├── home.pb.go
│ │ │ │ └── home.proto
│ │ │ └── README.md
│ │ └── hometask
│ │ └── home.go
│ ├── route
│ │ ├── route.go
│ └── third
│ └── homeapi
│ ├── home.go
│ └── protobuf
│ └── homepb
│ ├── home.pb.go
│ └── home.proto
├── conf
│ └── app.toml
├── main.go
└── tools
└── build.sh
@reference example/app/modules/home/homehttp/home.go
@reference example/app/modules/home/homecmd/home.go
@reference example/app/modules/home/hometask/home.go
@reference example/app/modules/home/homerpc/home.go
- 位置:
conf/app.toml
- 解析:
conf.go
- 使用:
@reference libs/orm/orm.go line 29
- 全局容器:
com.go
- 使用:
@reference libs/rds/redis_test.go
dao model http rpc task cmd
在项目根目录下,使用yago创建模块 新创建的模块会自动将路由加载到myapp/routes中
cd myapp
yago new -m newmodule
# 系统级错误定义处
error.go
# 使用
@reference example/app/modules/homehttp/home.go::AddAction
- 目录规范
@see example/app/third
- http-api 使用样例
@reference example/app/third/homeapi/home.go