hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
286 stars 24 forks source link

Golang: MonoRepo Practice #136

Open hhstore opened 5 years ago

hhstore commented 5 years ago

go 大仓库组织代码实践:

业务代码(微服务)推荐目录结构:


app/
    srv1/ 业务名称
        api/ 
            - http
            - rpc/grpc
        admin/ 管理端相关
        interface/ or gateway/ 内部接口层(网关) (可选)
        job/ or task/ 异步任务/定时任务/批处理
        server/ (可选)
        cmd/ 启动入口
            - main.go
        conf/ 配置
            - conf.toml
        dao/ 
            - crud.go
        logic/ 业务逻辑
            - business.go
        handler/ 请求处理(可选)
            - req_handler.go
        router/ 路由层(可选)
        model/
            - xx.proto
        util/
    srv2/
        api/
        cmd/
        conf/
        dao/
        model/
        util/

common/ or pkg/  公共代码库, 插件, 中间件封装
    util/ 公共代码
    middleware/ 中间件封装
    plugin/ 插件封装
    base/ 基础代码

脚手架:

构建工具:

hhstore commented 5 years ago

实践案例:

babel:

hhstore commented 5 years ago

git commit msg 规范:

提交信息-最佳实践:

chore: run tests on travis ci
fix(server): send cors headers

feat(blog): add comment section

描述关键词:

build
ci
chore
docs
feat
fix
perf
refactor
revert
style
test

Google 提交规范:

image