Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
|
1 year ago | |
---|---|---|
api | 1 year ago | |
build | 1 year ago | |
cmd | 1 year ago | |
configs | 1 year ago | |
deps | 1 year ago | |
docs | 1 year ago | |
internal | 1 year ago | |
.gitignore | 1 year ago | |
.gitmodules | 1 year ago | |
Jenkinsfile | 1 year ago | |
LICENSE | 1 year ago | |
Makefile | 1 year ago | |
README.md | 1 year ago | |
go.mod | 1 year ago | |
go.sum | 1 year ago | |
sonar-project.properties | 1 year ago |
internal/routers/redirect_utils.go
直接转发internal/httpclient/client.go
进行请求参考文档Standard Go Project Layout
cmd/
: 项目入口,main函数。internal/
: 业务代码。internal为不需要被外部repo调用的代码,聚合层几乎都是业务逻辑,无需被外部引用。deps/
: 本地依赖包。非公共仓库的。放在vendor文件夹执行go mod vendor
会丢失文件,故放到不被go直接管理的文件夹下api/
: openapi/swagger文档文件docs/
: 项目设计文档configs/
: config-template或默认config文件build/
: 构建代码,如Dockerfiledeployments/
: 部署代码,如k8s yaml等go.mod
, go.sum
: golang依赖管理代码Makefile
: 常用命令.gitmodules
: git submodule定义,通过git submodule add
自动生成configs
: 应用配置文件映射结构体daos
:调用数据库逻辑代码database
: 数据库驱动相关代码middlewares
:中间件,如auth等models
:数据库结构体定义requests
:请求结构体定义responses
:响应结构体定义routers
:路由管理services
:应用逻辑函数go get -u github.com/swaggo/swag/cmd/swag
$GOPATH/bin
添加到PATH
swag init -g cmd/api_server.go -o api
go run cmd/api_server.go
http://<HOST>:<PORT>/swagger/index.html
找到API文档api/
文件夹下的内容导入yapiapulis代码日常托管在自建gitlab, 但部分代码可能开源至github,故mod命名统一以github.com/apulis
开头
使用git submodule add
命令
git submodule add git@apulis-gitlab.apulis.cn:sdk/simple-gin-logger.git deps/simple-gin-logger
在go.mod添加replace,用本地deps
目录下的替换github.com/apulis
相关依赖
replace github.com/apulis/simple-gin-logger v0.0.0 => ./deps/simple-gin-logger
git submodule init
git submodule update
config.template.yaml
编辑config.yaml
文件go run cmd/api_server.go
get-deps
: 加载submodule, 并把第三方依赖下载到本地vendor/
文件夹下vet-check-all
: 使用go vet工具扫描代码(vet工具golang自带)gosec-check-all
: 使用gosec工具扫描代码(gosec工具go get github.com/securego/gosec/cmd/gosec
)build-api-server-bin
: 构建二进制文件build-api-server-docker
: 构建dockergen-swagger
: 生成swagger文档依瞳人工智能平台用户管理服务端
Text Go Dockerfile Makefile other