├── tmp └── .gitkeep ├── pytest.ini ├── mono-repo ├── gin │ ├── {{cookiecutter.repo_name}} │ │ ├── .gitmodules │ │ ├── pkg │ │ │ └── .gitkeep │ │ ├── script │ │ │ └── .gitkeep │ │ ├── deploy │ │ │ ├── local │ │ │ │ └── Makefile │ │ │ └── staging │ │ │ │ └── Makefile │ │ ├── infra │ │ │ └── tool │ │ │ │ └── .gitkeep │ │ ├── app │ │ │ ├── std │ │ │ │ ├── proto │ │ │ │ │ ├── error │ │ │ │ │ │ └── code.proto │ │ │ │ │ └── config │ │ │ │ │ │ └── config.proto │ │ │ │ ├── Makefile │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ ├── basic │ │ │ │ ├── user │ │ │ │ │ ├── identity │ │ │ │ │ │ ├── docs │ │ │ │ │ │ │ └── .gitkeep │ │ │ │ │ │ ├── configs │ │ │ │ │ │ │ └── configs.toml │ │ │ │ │ │ ├── proto │ │ │ │ │ │ │ ├── api │ │ │ │ │ │ │ │ └── api.proto │ │ │ │ │ │ │ ├── model │ │ │ │ │ │ │ │ └── model.proto │ │ │ │ │ │ │ └── config │ │ │ │ │ │ │ │ └── config.proto │ │ │ │ │ │ ├── cmd │ │ │ │ │ │ │ └── main.go │ │ │ │ │ │ ├── internal │ │ │ │ │ │ │ ├── dao │ │ │ │ │ │ │ │ ├── db │ │ │ │ │ │ │ │ │ └── db.go │ │ │ │ │ │ │ │ ├── meta.go │ │ │ │ │ │ │ │ ├── mq │ │ │ │ │ │ │ │ │ └── mq.go │ │ │ │ │ │ │ │ ├── http │ │ │ │ │ │ │ │ │ └── http.go │ │ │ │ │ │ │ │ ├── rpc │ │ │ │ │ │ │ │ │ └── rpc.go │ │ │ │ │ │ │ │ └── cache │ │ │ │ │ │ │ │ │ └── cache.go │ │ │ │ │ │ │ ├── service │ │ │ │ │ │ │ │ └── service.go │ │ │ │ │ │ │ └── domain │ │ │ │ │ │ │ │ └── identity │ │ │ │ │ │ │ │ └── identity.go │ │ │ │ │ │ ├── readme.md │ │ │ │ │ │ ├── readme-en.md │ │ │ │ │ │ └── Makefile │ │ │ │ │ ├── readme.md │ │ │ │ │ └── readme-en.md │ │ │ │ └── {{cookiecutter.basic_app_name}} │ │ │ │ │ ├── docs │ │ │ │ │ └── .gitkeep │ │ │ │ │ ├── configs │ │ │ │ │ └── configs.toml │ │ │ │ │ ├── proto │ │ │ │ │ ├── api │ │ │ │ │ │ └── api.proto │ │ │ │ │ ├── config │ │ │ │ │ │ └── config.proto │ │ │ │ │ └── model │ │ │ │ │ │ └── model.proto │ │ │ │ │ ├── cmd │ │ │ │ │ └── main.go │ │ │ │ │ └── internal │ │ │ │ │ ├── dao │ │ │ │ │ ├── db │ │ │ │ │ │ └── db.go │ │ │ │ │ ├── meta.go │ │ │ │ │ ├── mq │ │ │ │ │ │ └── mq.go │ │ │ │ │ ├── rpc │ │ │ │ │ │ └── rpc.go │ │ │ │ │ ├── cache │ │ │ │ │ │ └── cache.go │ │ │ │ │ └── http │ │ │ │ │ │ └── http.go │ │ │ │ │ ├── service │ │ │ │ │ └── service.go │ │ │ │ │ └── domain │ │ │ │ │ └── {{cookiecutter.basic_app_name}} │ │ │ │ │ └── {{cookiecutter.basic_app_name}}.go │ │ │ └── biz │ │ │ │ └── {{cookiecutter.biz_app_name}} │ │ │ │ └── cmd │ │ │ │ └── main.go │ │ ├── README.MD │ │ ├── .circleci │ │ │ └── config.yml │ │ ├── .goreleaser.yml │ │ ├── .codeclimate.yml │ │ ├── Makefile │ │ ├── .pre-commit-hooks.yaml │ │ ├── .gitignore │ │ ├── go.mod │ │ ├── .codecov.yml │ │ └── .pre-commit-config.yaml │ ├── hooks │ │ ├── post_gen_project.py │ │ └── pre_gen_project.py │ └── cookiecutter.json ├── rs │ ├── {{cookiecutter.repo_name}} │ │ ├── .gitmodules │ │ ├── Taskfile.yml │ │ ├── pkg │ │ │ ├── .gitkeep │ │ │ ├── readme.md │ │ │ └── readme-en.md │ │ ├── tmp │ │ │ └── .gitkeep │ │ ├── script │ │ │ └── .gitkeep │ │ ├── deploy │ │ │ ├── staging │ │ │ │ └── Makefile │ │ │ ├── production │ │ │ │ ├── templates │ │ │ │ │ ├── install-java.sh.tpl │ │ │ │ │ ├── install-docker.sh.tpl │ │ │ │ │ └── install-base.sh.tpl │ │ │ │ └── terraform-aws │ │ │ │ │ └── gitignore.tf │ │ │ ├── local │ │ │ │ ├── infra-mq-rabbitmq.yml │ │ │ │ ├── infra-kv-etcd.sh │ │ │ │ └── infra-kv-etcd.yml │ │ │ └── readme.md │ │ ├── infra │ │ │ ├── tool │ │ │ │ └── .gitkeep │ │ │ ├── readme.md │ │ │ └── readme-en.md │ │ ├── app │ │ │ ├── std │ │ │ │ ├── proto │ │ │ │ │ ├── config │ │ │ │ │ │ └── config.proto │ │ │ │ │ └── error │ │ │ │ │ │ └── code.proto │ │ │ │ ├── Makefile │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ ├── biz │ │ │ │ ├── {{cookiecutter.biz_app_name}} │ │ │ │ │ ├── readme.md │ │ │ │ │ └── readme-en.md │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ └── basic │ │ │ │ ├── user │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ │ ├── admin │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ ├── Makefile.install.mk │ │ ├── .codeclimate.yml │ │ ├── .pre-commit-hooks.yml │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── .codecov.yml │ │ └── .pre-commit-config.yml │ ├── cookiecutter.json │ └── hooks │ │ ├── post_gen_project.py │ │ └── pre_gen_project.py ├── go-kratos │ ├── {{cookiecutter.repo_name}} │ │ ├── .gitmodules │ │ ├── pkg │ │ │ ├── .gitkeep │ │ │ ├── x │ │ │ │ ├── README.md │ │ │ │ ├── validate │ │ │ │ │ └── README.md │ │ │ │ ├── errors │ │ │ │ │ └── errors.proto │ │ │ │ └── google │ │ │ │ │ └── api │ │ │ │ │ └── annotations.proto │ │ │ ├── util │ │ │ │ └── pagination │ │ │ │ │ └── pagination.go │ │ │ ├── errors │ │ │ │ └── auth │ │ │ │ │ └── error.go │ │ │ ├── readme.md │ │ │ └── readme-en.md │ │ ├── script │ │ │ └── .gitkeep │ │ ├── tmp │ │ │ └── .gitkeep │ │ ├── infra │ │ │ ├── tool │ │ │ │ └── .gitkeep │ │ │ ├── readme.md │ │ │ └── readme-en.md │ │ ├── deploy │ │ │ ├── staging │ │ │ │ └── Makefile │ │ │ ├── production │ │ │ │ ├── templates │ │ │ │ │ ├── install-java.sh.tpl │ │ │ │ │ ├── install-docker.sh.tpl │ │ │ │ │ └── install-base.sh.tpl │ │ │ │ └── terraform-aws │ │ │ │ │ └── gitignore.tf │ │ │ ├── local │ │ │ │ ├── infra-mq-rabbitmq.yml │ │ │ │ ├── infra-kv-etcd.sh │ │ │ │ └── infra-kv-etcd.yml │ │ │ └── readme.md │ │ ├── app │ │ │ ├── std │ │ │ │ ├── proto │ │ │ │ │ ├── config │ │ │ │ │ │ └── config.proto │ │ │ │ │ └── error │ │ │ │ │ │ └── code.proto │ │ │ │ ├── Makefile │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ ├── unit │ │ │ │ ├── {{cookiecutter.biz_app_name}} │ │ │ │ │ ├── cmd │ │ │ │ │ │ └── main.go │ │ │ │ │ ├── readme.md │ │ │ │ │ └── readme-en.md │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ └── basic │ │ │ │ ├── user │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ │ ├── admin │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ ├── api │ │ │ ├── basic │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ ├── unit │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ ├── readme.md │ │ │ └── readme-en.md │ │ ├── client │ │ │ ├── admin │ │ │ │ ├── web │ │ │ │ │ ├── readme.md │ │ │ │ │ └── readme-en.md │ │ │ │ ├── desktop │ │ │ │ │ ├── readme.md │ │ │ │ │ └── readme-en.md │ │ │ │ └── mobile │ │ │ │ │ ├── readme.md │ │ │ │ │ └── readme-en.md │ │ │ ├── user │ │ │ │ ├── web │ │ │ │ │ ├── readme.md │ │ │ │ │ └── readme-en.md │ │ │ │ ├── desktop │ │ │ │ │ ├── readme.md │ │ │ │ │ └── readme-en.md │ │ │ │ └── mobile │ │ │ │ │ ├── readme.md │ │ │ │ │ └── readme-en.md │ │ │ ├── readme.md │ │ │ └── readme-en.md │ │ ├── go.mod │ │ ├── .goreleaser.yml │ │ ├── Makefile.install.mk │ │ ├── .codeclimate.yml │ │ ├── .pre-commit-hooks.yml │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── .codecov.yml │ │ └── .pre-commit-config.yml │ ├── cookiecutter.json │ └── hooks │ │ ├── post_gen_project.py │ │ └── pre_gen_project.py └── go-zero │ ├── {{cookiecutter.go_module_name}} │ ├── .gitmodules │ ├── pkg │ │ ├── .gitkeep │ │ ├── readme.md │ │ └── readme-en.md │ ├── tmp │ │ └── .gitkeep │ ├── script │ │ └── .gitkeep │ ├── deploy │ │ ├── staging │ │ │ └── Makefile │ │ ├── production │ │ │ ├── templates │ │ │ │ ├── install-java.sh.tpl │ │ │ │ ├── install-docker.sh.tpl │ │ │ │ └── install-base.sh.tpl │ │ │ └── terraform-aws │ │ │ │ └── gitignore.tf │ │ └── local │ │ │ ├── .env.example │ │ │ ├── infra-mq-rabbitmq.yml │ │ │ ├── infra-kv-etcd.sh │ │ │ └── infra-kv-etcd.yml │ ├── infra │ │ ├── tool │ │ │ └── .gitkeep │ │ ├── readme.md │ │ └── readme-en.md │ ├── app │ │ ├── basic │ │ │ ├── demo │ │ │ │ ├── docs │ │ │ │ │ └── .gitkeep │ │ │ │ ├── proto │ │ │ │ │ ├── rpc │ │ │ │ │ │ └── rpc.go │ │ │ │ │ ├── model │ │ │ │ │ │ ├── model.go │ │ │ │ │ │ ├── model.proto │ │ │ │ │ │ ├── hello.go │ │ │ │ │ │ └── graphql │ │ │ │ │ │ │ └── graph_test.go │ │ │ │ │ └── api │ │ │ │ │ │ ├── api.go │ │ │ │ │ │ ├── api.proto │ │ │ │ │ │ └── api_queue.go │ │ │ │ ├── internal │ │ │ │ │ ├── dao │ │ │ │ │ │ ├── db │ │ │ │ │ │ │ ├── hello_test.go │ │ │ │ │ │ │ ├── demo.go │ │ │ │ │ │ │ ├── hello.go │ │ │ │ │ │ │ ├── db_test.go │ │ │ │ │ │ │ └── user.go │ │ │ │ │ │ ├── http │ │ │ │ │ │ │ ├── demo.go │ │ │ │ │ │ │ └── http.go │ │ │ │ │ │ ├── mq │ │ │ │ │ │ │ ├── hello_test.go │ │ │ │ │ │ │ ├── demo.go │ │ │ │ │ │ │ ├── mq_test.go │ │ │ │ │ │ │ ├── hello.go │ │ │ │ │ │ │ ├── mq.go │ │ │ │ │ │ │ └── block.go │ │ │ │ │ │ ├── rpc │ │ │ │ │ │ │ ├── demo.go │ │ │ │ │ │ │ ├── rpc.go │ │ │ │ │ │ │ └── inner.go │ │ │ │ │ │ ├── cache │ │ │ │ │ │ │ ├── demo.go │ │ │ │ │ │ │ └── hello.go │ │ │ │ │ │ └── graphql │ │ │ │ │ │ │ ├── graphql_test.go │ │ │ │ │ │ │ ├── chain.go │ │ │ │ │ │ │ ├── chain_test.go │ │ │ │ │ │ │ └── graphql.go │ │ │ │ │ ├── server │ │ │ │ │ │ ├── server.go │ │ │ │ │ │ ├── job.go │ │ │ │ │ │ ├── admin.go │ │ │ │ │ │ ├── outer.go │ │ │ │ │ │ └── inner.go │ │ │ │ │ ├── domain │ │ │ │ │ │ └── demo │ │ │ │ │ │ │ ├── block_test.go │ │ │ │ │ │ │ ├── demo_test.go │ │ │ │ │ │ │ ├── hello.go │ │ │ │ │ │ │ └── demo.go │ │ │ │ │ ├── service │ │ │ │ │ │ ├── admin │ │ │ │ │ │ │ ├── admin.go │ │ │ │ │ │ │ └── handler.go │ │ │ │ │ │ ├── inner │ │ │ │ │ │ │ ├── inner.go │ │ │ │ │ │ │ └── handler.go │ │ │ │ │ │ └── outer │ │ │ │ │ │ │ └── outer.go │ │ │ │ │ └── router │ │ │ │ │ │ ├── router.go │ │ │ │ │ │ └── v1_admin.go │ │ │ │ └── cmd │ │ │ │ │ └── main.go │ │ │ ├── user │ │ │ │ ├── readme.md │ │ │ │ └── readme-en.md │ │ │ ├── readme.md │ │ │ └── readme-en.md │ │ ├── std │ │ │ ├── proto │ │ │ │ ├── config │ │ │ │ │ └── config.proto │ │ │ │ └── error │ │ │ │ │ └── code.proto │ │ │ ├── Makefile │ │ │ ├── readme.md │ │ │ └── readme-en.md │ │ └── biz │ │ │ ├── {{cookiecutter.biz_app_name}} │ │ │ └── cmd │ │ │ │ └── main.go │ │ │ ├── readme.md │ │ │ └── readme-en.md │ ├── .circleci │ │ └── config.yml │ ├── go.mod │ ├── .goreleaser.yml │ ├── Makefile.install.mk │ ├── .codeclimate.yml │ ├── .pre-commit-hooks.yaml │ ├── .gitignore │ ├── LICENSE │ ├── .codecov.yml │ └── .pre-commit-config.yaml │ ├── cookiecutter.json │ └── hooks │ ├── post_gen_project.py │ └── pre_gen_project.py ├── single-app ├── gin │ ├── {{cookiecutter.app_name}} │ │ ├── docs │ │ │ └── .gitkeep │ │ ├── proto │ │ │ ├── model │ │ │ │ └── model.go │ │ │ └── api │ │ │ │ └── api.go │ │ ├── readme.md │ │ ├── readme-en.md │ │ ├── internal │ │ │ ├── dao │ │ │ │ ├── db │ │ │ │ │ ├── db.go │ │ │ │ │ └── demo.go │ │ │ │ ├── mq │ │ │ │ │ ├── mq.go │ │ │ │ │ └── demo.go │ │ │ │ ├── rpc │ │ │ │ │ ├── rpc.go │ │ │ │ │ └── demo.go │ │ │ │ ├── http │ │ │ │ │ ├── http.go │ │ │ │ │ └── demo.go │ │ │ │ └── cache │ │ │ │ │ ├── cache.go │ │ │ │ │ └── demo.go │ │ │ ├── domain │ │ │ │ └── {{cookiecutter.app_name}} │ │ │ │ │ ├── demo.go │ │ │ │ │ └── {{cookiecutter.app_name}}.go │ │ │ ├── service │ │ │ │ └── service.go │ │ │ └── router │ │ │ │ └── router.go │ │ └── Makefile │ ├── hooks │ │ ├── post_gen_project.py │ │ └── pre_gen_project.py │ └── cookiecutter.json └── go-zero │ ├── {{cookiecutter.app_name}} │ ├── docs │ │ └── .gitkeep │ ├── tmp │ │ └── .gitkeep │ ├── proto │ │ ├── rpc │ │ │ └── rpc.go │ │ ├── model │ │ │ ├── model.go │ │ │ ├── model.proto │ │ │ ├── hello.go │ │ │ └── graphql │ │ │ │ └── graph_test.go │ │ └── api │ │ │ ├── api.go │ │ │ ├── api.proto │ │ │ └── api_queue.go │ ├── internal │ │ ├── dao │ │ │ ├── db │ │ │ │ ├── hello_test.go │ │ │ │ ├── demo.go │ │ │ │ ├── hello.go │ │ │ │ ├── db_test.go │ │ │ │ └── user.go │ │ │ ├── http │ │ │ │ ├── demo.go │ │ │ │ └── http.go │ │ │ ├── mq │ │ │ │ ├── hello_test.go │ │ │ │ ├── demo.go │ │ │ │ ├── mq_test.go │ │ │ │ ├── hello.go │ │ │ │ ├── mq.go │ │ │ │ └── block.go │ │ │ ├── rpc │ │ │ │ ├── demo.go │ │ │ │ ├── rpc.go │ │ │ │ └── inner.go │ │ │ ├── cache │ │ │ │ ├── demo.go │ │ │ │ └── hello.go │ │ │ └── graphql │ │ │ │ ├── graphql_test.go │ │ │ │ ├── chain.go │ │ │ │ ├── chain_test.go │ │ │ │ └── graphql.go │ │ ├── server │ │ │ ├── server.go │ │ │ ├── job.go │ │ │ ├── admin.go │ │ │ ├── outer.go │ │ │ └── inner.go │ │ ├── domain │ │ │ └── {{cookiecutter.app_name}} │ │ │ │ ├── block_test.go │ │ │ │ ├── {{cookiecutter.app_name}}_test.go │ │ │ │ ├── hello.go │ │ │ │ └── {{cookiecutter.app_name}}.go │ │ ├── service │ │ │ ├── admin │ │ │ │ ├── admin.go │ │ │ │ └── handler.go │ │ │ ├── inner │ │ │ │ ├── inner.go │ │ │ │ └── handler.go │ │ │ └── outer │ │ │ │ └── outer.go │ │ └── router │ │ │ ├── router.go │ │ │ └── v1_admin.go │ └── cmd │ │ └── main.go │ ├── hooks │ ├── post_gen_project.py │ └── pre_gen_project.py │ └── cookiecutter.json ├── library-repo ├── {{cookiecutter.repo_name}} │ └── {{cookiecutter.repo_name}}.go └── cookiecutter.json ├── requirements_dev.txt ├── .github ├── ISSUE_TEMPLATE │ ├── question.md │ ├── feature_request.md │ └── bug_report.md └── workflows │ ├── changelog.yml │ ├── sync.yml │ └── contributors.yml ├── Makefile ├── .editorconfig └── .gitignore /tmp/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | testpaths = tests/ 3 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/pkg/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/Taskfile.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/pkg/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/tmp/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/script/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/script/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/docs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/docs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/tmp/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/deploy/local/Makefile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/infra/tool/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/pkg/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/script/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/tmp/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/pkg/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/tmp/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/deploy/staging/Makefile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/infra/tool/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/deploy/staging/Makefile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/infra/tool/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/script/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/std/proto/error/code.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/deploy/staging/Makefile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/deploy/staging/Makefile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/infra/tool/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/std/proto/config/config.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/std/proto/error/code.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/docs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/std/proto/config/config.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/docs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/proto/rpc/rpc.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/pkg/x/README.md: -------------------------------------------------------------------------------- 1 | # third_party 2 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/std/proto/config/config.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/std/proto/error/code.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/proto/model/model.go: -------------------------------------------------------------------------------- 1 | package model 2 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/proto/model/model.go: -------------------------------------------------------------------------------- 1 | package model 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/configs/configs.toml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/proto/api/api.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/proto/model/model.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/cmd/main.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/proto/config/config.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/db/hello_test.go: -------------------------------------------------------------------------------- 1 | package db 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/docs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/proto/rpc/rpc.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/internal/dao/db/db.go: -------------------------------------------------------------------------------- 1 | package db 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/internal/dao/meta.go: -------------------------------------------------------------------------------- 1 | package dao 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/internal/dao/mq/mq.go: -------------------------------------------------------------------------------- 1 | package mq 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/configs/configs.toml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/proto/api/api.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/std/proto/config/config.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/std/proto/error/code.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/proto/model/model.go: -------------------------------------------------------------------------------- 1 | package model 2 | -------------------------------------------------------------------------------- /library-repo/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}.go: -------------------------------------------------------------------------------- 1 | package {{cookiecutter.repo_name}} 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/internal/dao/http/http.go: -------------------------------------------------------------------------------- 1 | package http 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/internal/dao/rpc/rpc.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/proto/config/config.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/proto/model/model.proto: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/biz/{{cookiecutter.biz_app_name}}/cmd/main.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/api/basic/readme.md: -------------------------------------------------------------------------------- 1 | # api/basic: 2 | 3 | - 基础服务 API 定义 4 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/api/unit/readme.md: -------------------------------------------------------------------------------- 1 | # api/unit: 2 | 3 | - 业务单元 API 定义 4 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/internal/dao/cache/cache.go: -------------------------------------------------------------------------------- 1 | package cache 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/internal/service/service.go: -------------------------------------------------------------------------------- 1 | package service 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/cmd/main.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/unit/{{cookiecutter.biz_app_name}}/cmd/main.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/db/hello_test.go: -------------------------------------------------------------------------------- 1 | package db 2 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/biz/{{cookiecutter.biz_app_name}}/cmd/main.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # {{cookiecutter.app_name}} 3 | 4 | - awesome app service 5 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/proto/model/model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package model; 4 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/internal/domain/identity/identity.go: -------------------------------------------------------------------------------- 1 | package identity 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/internal/dao/db/db.go: -------------------------------------------------------------------------------- 1 | package db 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/internal/dao/meta.go: -------------------------------------------------------------------------------- 1 | package dao 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/internal/dao/mq/mq.go: -------------------------------------------------------------------------------- 1 | package mq 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/internal/dao/rpc/rpc.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # user: 3 | 4 | - 账号系统, 支持各种第三方登录方式 5 | 6 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/internal/dao/cache/cache.go: -------------------------------------------------------------------------------- 1 | package cache 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/internal/dao/http/http.go: -------------------------------------------------------------------------------- 1 | package http 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/internal/service/service.go: -------------------------------------------------------------------------------- 1 | package service 2 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/README.MD: -------------------------------------------------------------------------------- 1 | 2 | # {{cookiecutter.repo_name}} 3 | 4 | - awesome project 5 | - mono repo 6 | 7 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/proto/model/model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package model; 4 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/biz/{{cookiecutter.biz_app_name}}/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # {{cookiecutter.biz_app_name}}: 4 | 5 | - new app -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | pytest==5.3.1 2 | tox==3.14.1 3 | cookiecutter>=1.4.0 4 | pytest-cookies==0.4.0 5 | alabaster==0.7.12 6 | watchdog==0.9.0 7 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | # {{cookiecutter.app_name}} 4 | 5 | - awesome app service 6 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/api/basic/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # api/basic: 3 | 4 | - Basic service API definition 5 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/api/unit/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # api/unit: 3 | 4 | - Business Unit API Definition 5 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/unit/{{cookiecutter.biz_app_name}}/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # {{cookiecutter.biz_app_name}}: 4 | 5 | - new app -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/std/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | .PHONY: proto 4 | proto: 5 | protoc --proto_path=. --go_out=${MODIFY}:. ./proto/*.proto 6 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/std/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | .PHONY: proto 4 | proto: 5 | protoc --proto_path=. --go_out=${MODIFY}:. ./proto/*.proto 6 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/std/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | .PHONY: proto 4 | proto: 5 | protoc --proto_path=. --go_out=${MODIFY}:. ./proto/*.proto 6 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/pkg/x/validate/README.md: -------------------------------------------------------------------------------- 1 | # protoc-gen-validate (PGV) 2 | 3 | * https://github.com/envoyproxy/protoc-gen-validate 4 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/std/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | .PHONY: proto 4 | proto: 5 | protoc --proto_path=. --go_out=${MODIFY}:. ./proto/*.proto 6 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/biz/readme.md: -------------------------------------------------------------------------------- 1 | # app/biz: 2 | 3 | 4 | - 业务服务列表: 5 | 6 | 7 | ## 说明: 8 | 9 | - 具体业务切分 10 | - 微服务列表 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Ask a question about this project 4 | title: "[question]" 5 | labels: question 6 | assignees: '' 7 | 8 | --- 9 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/unit/readme.md: -------------------------------------------------------------------------------- 1 | # app/unit: 2 | 3 | 4 | - 业务服务列表: 5 | 6 | 7 | ## 说明: 8 | 9 | - 具体业务切分 10 | - 微服务列表 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/biz/readme.md: -------------------------------------------------------------------------------- 1 | # app/biz: 2 | 3 | 4 | - 业务服务列表: 5 | 6 | 7 | ## 说明: 8 | 9 | - 具体业务切分 10 | - 微服务列表 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/biz/{{cookiecutter.biz_app_name}}/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | # {{cookiecutter.biz_app_name}}: 5 | 6 | - new app 7 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/unit/{{cookiecutter.biz_app_name}}/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | # {{cookiecutter.biz_app_name}}: 5 | 6 | - new app 7 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/basic/user/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # user: 3 | 4 | - union 5 | - 用户中心: 6 | - 账户系统 7 | - 登录鉴权 8 | - 用户角色 9 | - 用户权限 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | # user: 4 | 5 | - Account system, support various third-party login methods 6 | 7 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # user: 3 | 4 | - union 5 | - 用户中心: 6 | - 账户系统 7 | - 登录鉴权 8 | - 用户角色 9 | - 用户权限 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # 2 | # ref: 3 | # - https://circleci.com/docs/2.0/language-go/ 4 | # - https://github.com/golangci/golangci-lint/issues/250 5 | # 6 | # 7 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/basic/user/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # user: 3 | 4 | - union 5 | - 用户中心: 6 | - 账户系统 7 | - 登录鉴权 8 | - 用户角色 9 | - 用户权限 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/pkg/util/pagination/pagination.go: -------------------------------------------------------------------------------- 1 | package pagination 2 | 3 | func GetPageOffset(pageNum, pageSize int64) int64 { 4 | return (pageNum - 1) * pageSize 5 | } 6 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/user/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # user: 3 | 4 | - union 5 | - 用户中心: 6 | - 账户系统 7 | - 登录鉴权 8 | - 用户角色 9 | - 用户权限 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/basic/admin/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # admin manager: 3 | 4 | - union 5 | - 统一 admin 管理后台服务: 6 | - 账户系统 7 | - 登录鉴权 8 | - 用户角色 9 | - 用户权限 10 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/{{cookiecutter.basic_app_name}}/internal/domain/{{cookiecutter.basic_app_name}}/{{cookiecutter.basic_app_name}}.go: -------------------------------------------------------------------------------- 1 | package {{cookiecutter.basic_app_name}} 2 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/basic/admin/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # admin manager: 3 | 4 | - union 5 | - 统一 admin 管理后台服务: 6 | - 账户系统 7 | - 登录鉴权 8 | - 用户角色 9 | - 用户权限 10 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # 2 | # ref: 3 | # - https://circleci.com/docs/2.0/language-go/ 4 | # - https://github.com/golangci/golangci-lint/issues/250 5 | # 6 | # 7 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/pkg/errors/auth/error.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import "github.com/go-kratos/kratos/v2/errors" 4 | 5 | var ErrAuthFail = errors.New(401, "Authentication failed", "Missing token or token incorrect") 6 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/proto/api/api.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | //type Response struct { 4 | // Message string `json:"message"` 5 | // Host string `json:"host"` 6 | //} 7 | // 8 | //type Request struct { 9 | //} 10 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/proto/api/api.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | //type Response struct { 4 | // Message string `json:"message"` 5 | // Host string `json:"host"` 6 | //} 7 | // 8 | //type Request struct { 9 | //} 10 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/biz/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # app/us: 3 | 4 | 5 | - List of business services: 6 | 7 | 8 | ## illustrate: 9 | 10 | - Specific business segmentation 11 | - list of microservices 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/proto/api/api.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | type HelloReq struct { 4 | Name string `json:"name"` 5 | Message string `json:"message"` 6 | } 7 | 8 | type HelloResp struct { 9 | Reply string `json:"reply"` 10 | } 11 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | # user: 4 | 5 | - union 6 | - User Center: 7 | - Account system 8 | - Login authentication 9 | - User roles 10 | - User rights 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/basic/user/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | # user: 4 | 5 | - union 6 | - User Center: 7 | - Account system 8 | - Login authentication 9 | - User roles 10 | - User rights 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/http/demo.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | type DemoHttp struct { 4 | } 5 | 6 | func newDemoHttp() *DemoHttp { 7 | return &DemoHttp{} 8 | } 9 | 10 | func (m *DemoHttp) Hello() (err error) { 11 | return nil 12 | } 13 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/basic/user/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | # user: 4 | 5 | - union 6 | - User Center: 7 | - Account system 8 | - Login authentication 9 | - User roles 10 | - User rights 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/unit/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # app/unit: 3 | 4 | 5 | - List of business services: 6 | 7 | 8 | ## illustrate: 9 | 10 | - Specific business segmentation 11 | - list of microservices 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/biz/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # app/us: 3 | 4 | 5 | - List of business services: 6 | 7 | 8 | ## illustrate: 9 | 10 | - Specific business segmentation 11 | - list of microservices 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/admin/web/readme.md: -------------------------------------------------------------------------------- 1 | # client: 2 | 3 | - 客户端 4 | - web/ 5 | - h5/ 6 | - admin/ 7 | - mobile/ 8 | - ios/ 9 | - android/ 10 | - desktop/ 11 | - macos/ 12 | - windows/ 13 | - linux/ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/user/web/readme.md: -------------------------------------------------------------------------------- 1 | # client: 2 | 3 | - 客户端 4 | - web/ 5 | - h5/ 6 | - admin/ 7 | - mobile/ 8 | - ios/ 9 | - android/ 10 | - desktop/ 11 | - macos/ 12 | - windows/ 13 | - linux/ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/user/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | # user: 4 | 5 | - union 6 | - User Center: 7 | - Account system 8 | - Login authentication 9 | - User roles 10 | - User rights 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/http/http.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | type Dao struct { 4 | Demo *DemoHttp 5 | } 6 | 7 | func New() *Dao { 8 | return &Dao{ 9 | Demo: newDemoHttp(), 10 | } 11 | } 12 | 13 | func (m *Dao) Close() { 14 | return 15 | } 16 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/admin/desktop/readme.md: -------------------------------------------------------------------------------- 1 | # client: 2 | 3 | - 客户端 4 | - web/ 5 | - h5/ 6 | - admin/ 7 | - mobile/ 8 | - ios/ 9 | - android/ 10 | - desktop/ 11 | - macos/ 12 | - windows/ 13 | - linux/ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/admin/mobile/readme.md: -------------------------------------------------------------------------------- 1 | # client: 2 | 3 | - 客户端 4 | - web/ 5 | - h5/ 6 | - admin/ 7 | - mobile/ 8 | - ios/ 9 | - android/ 10 | - desktop/ 11 | - macos/ 12 | - windows/ 13 | - linux/ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/user/desktop/readme.md: -------------------------------------------------------------------------------- 1 | # client: 2 | 3 | - 客户端 4 | - web/ 5 | - h5/ 6 | - admin/ 7 | - mobile/ 8 | - ios/ 9 | - android/ 10 | - desktop/ 11 | - macos/ 12 | - windows/ 13 | - linux/ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/user/mobile/readme.md: -------------------------------------------------------------------------------- 1 | # client: 2 | 3 | - 客户端 4 | - web/ 5 | - h5/ 6 | - admin/ 7 | - mobile/ 8 | - ios/ 9 | - android/ 10 | - desktop/ 11 | - macos/ 12 | - windows/ 13 | - linux/ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/http/demo.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | type DemoHttp struct { 4 | } 5 | 6 | func newDemoHttp() *DemoHttp { 7 | return &DemoHttp{} 8 | } 9 | 10 | func (m *DemoHttp) Hello() (err error) { 11 | return nil 12 | } 13 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/proto/api/api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package api; 4 | option go_package = "api"; 5 | 6 | 7 | message Request { 8 | string from = 1; 9 | } 10 | 11 | message Response { 12 | string message = 1; 13 | string host = 2; 14 | } 15 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/http/http.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | type Dao struct { 4 | Demo *DemoHttp 5 | } 6 | 7 | func New() *Dao { 8 | return &Dao{ 9 | Demo: newDemoHttp(), 10 | } 11 | } 12 | 13 | func (m *Dao) Close() { 14 | return 15 | } 16 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/basic/admin/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | # admin manager: 4 | 5 | - union 6 | - Unified admin management background services: 7 | - Account system 8 | - Login authentication 9 | - User roles 10 | - User rights 11 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/basic/admin/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | # admin manager: 4 | 5 | - union 6 | - Unified admin management background services: 7 | - Account system 8 | - Login authentication 9 | - User roles 10 | - User rights 11 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/proto/api/api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package api; 4 | option go_package = "api"; 5 | 6 | 7 | message Request { 8 | string from = 1; 9 | } 10 | 11 | message Response { 12 | string message = 1; 13 | string host = 2; 14 | } 15 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/admin/web/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # client: 3 | 4 | - Client 5 | - web/ 6 | - huh/ 7 | - admin/ 8 | - mobile/ 9 | - ios/ 10 | - android/ 11 | - desktop/ 12 | - macos/ 13 | - windows/ 14 | - linux/ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/user/web/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # client: 3 | 4 | - Client 5 | - web/ 6 | - huh/ 7 | - admin/ 8 | - mobile/ 9 | - ios/ 10 | - android/ 11 | - desktop/ 12 | - macos/ 13 | - windows/ 14 | - linux/ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/admin/desktop/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # client: 3 | 4 | - Client 5 | - web/ 6 | - huh/ 7 | - admin/ 8 | - mobile/ 9 | - ios/ 10 | - android/ 11 | - desktop/ 12 | - macos/ 13 | - windows/ 14 | - linux/ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/admin/mobile/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # client: 3 | 4 | - Client 5 | - web/ 6 | - huh/ 7 | - admin/ 8 | - mobile/ 9 | - ios/ 10 | - android/ 11 | - desktop/ 12 | - macos/ 13 | - windows/ 14 | - linux/ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/user/desktop/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # client: 3 | 4 | - Client 5 | - web/ 6 | - huh/ 7 | - admin/ 8 | - mobile/ 9 | - ios/ 10 | - android/ 11 | - desktop/ 12 | - macos/ 13 | - windows/ 14 | - linux/ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/user/mobile/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # client: 3 | 4 | - Client 5 | - web/ 6 | - huh/ 7 | - admin/ 8 | - mobile/ 9 | - ios/ 10 | - android/ 11 | - desktop/ 12 | - macos/ 13 | - windows/ 14 | - linux/ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/api/readme.md: -------------------------------------------------------------------------------- 1 | # api: 2 | 3 | - 所有服务的 API: 4 | - protobuf 定义: 5 | 6 | ## 两种管理方案: 7 | 8 | - 集中管理 PROTO API 定义: 9 | - 方便 client 调用 10 | - 分散管理 PROTO API 定义: 11 | - 方便单个服务的维护者开发 12 | 13 | ## 折中方案: 14 | 15 | - 写一个 sync 脚本. 16 | - 定期自动同步各服务内的 proto api 定义到 api/ 文件夹下. 17 | 18 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/basic/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # app/basic: 4 | 5 | - 基础服务 6 | 7 | 8 | ## 说明: 9 | 10 | - 通用业务场景下, 公共基础服务: 11 | - user: register/login/ 12 | - auth: 13 | - permission: 14 | - role: 15 | - vip-account: 16 | - security: 17 | - push: 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/better-go/pkg/x/go-zero/cmd" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/server" 7 | ) 8 | 9 | func main() { 10 | // auto select: 11 | cmd.Runner(server.NewServerSelector()) 12 | } 13 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/basic/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # app/basic: 4 | 5 | - 基础服务 6 | 7 | 8 | ## 说明: 9 | 10 | - 通用业务场景下, 公共基础服务: 11 | - user: register/login/ 12 | - auth: 13 | - permission: 14 | - role: 15 | - vip-account: 16 | - security: 17 | - push: 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/better-go/pkg/x/go-zero/cmd" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/server" 7 | ) 8 | 9 | func main() { 10 | // auto select: 11 | cmd.Runner(server.NewServerSelector()) 12 | } 13 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/deploy/production/templates/install-java.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[---Begin install-java.sh---]" 4 | 5 | echo "Install Java" 6 | curl https://raw.githubusercontent.com/hashicorp/guides-configuration/master/nomad/scripts/install-java.sh | bash 7 | 8 | echo "[---install-java.sh Complete---]" 9 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/deploy/production/templates/install-java.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[---Begin install-java.sh---]" 4 | 5 | echo "Install Java" 6 | curl https://raw.githubusercontent.com/hashicorp/guides-configuration/master/nomad/scripts/install-java.sh | bash 7 | 8 | echo "[---install-java.sh Complete---]" 9 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # app/basic: 4 | 5 | - 基础服务 6 | 7 | 8 | ## 说明: 9 | 10 | - 通用业务场景下, 公共基础服务: 11 | - user: register/login/ 12 | - auth: 13 | - permission: 14 | - role: 15 | - vip-account: 16 | - security: 17 | - push: 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/deploy/production/templates/install-java.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[---Begin install-java.sh---]" 4 | 5 | echo "Install Java" 6 | curl https://raw.githubusercontent.com/hashicorp/guides-configuration/master/nomad/scripts/install-java.sh | bash 7 | 8 | echo "[---install-java.sh Complete---]" 9 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/deploy/production/templates/install-docker.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[---Begin install-docker.sh---]" 4 | 5 | echo "Install Docker" 6 | curl https://raw.githubusercontent.com/hashicorp/guides-configuration/master/nomad/scripts/install-docker.sh | bash 7 | 8 | echo "[---install-docker.sh Complete---]" 9 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/pkg/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # pkg: 4 | 5 | ## 说明: 6 | 7 | - 本目录, 用于存放与`业务无关`的通用代码 8 | - 常用的 utility, wrap, hook, 中间件等等 9 | - 后期可逐步迁移到外部, 供其他项目使用. 10 | 11 | 12 | ## 区别 app/std 目录: 13 | 14 | - app/std 是`项目内`全局`公共依赖`: 标准状态码, 标准配置 15 | 16 | 17 | ## 目录结构建议: 18 | 19 | - 参考 go 标准库目录组织方式. 20 | 21 | 22 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/deploy/production/templates/install-docker.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[---Begin install-docker.sh---]" 4 | 5 | echo "Install Docker" 6 | curl https://raw.githubusercontent.com/hashicorp/guides-configuration/master/nomad/scripts/install-docker.sh | bash 7 | 8 | echo "[---install-docker.sh Complete---]" 9 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/pkg/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # pkg: 4 | 5 | ## 说明: 6 | 7 | - 本目录, 用于存放与`业务无关`的通用代码 8 | - 常用的 utility, wrap, hook, 中间件等等 9 | - 后期可逐步迁移到外部, 供其他项目使用. 10 | 11 | 12 | ## 区别 app/std 目录: 13 | 14 | - app/std 是`项目内`全局`公共依赖`: 标准状态码, 标准配置 15 | 16 | 17 | ## 目录结构建议: 18 | 19 | - 参考 go 标准库目录组织方式. 20 | 21 | 22 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/go.mod: -------------------------------------------------------------------------------- 1 | module {{cookiecutter.repo_name}} 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/go-kratos/kratos/v2 v2.2.0 7 | github.com/google/wire v0.5.0 8 | google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf 9 | google.golang.org/grpc v1.44.0 10 | google.golang.org/protobuf v1.27.1 11 | ) 12 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/deploy/production/templates/install-docker.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[---Begin install-docker.sh---]" 4 | 5 | echo "Install Docker" 6 | curl https://raw.githubusercontent.com/hashicorp/guides-configuration/master/nomad/scripts/install-docker.sh | bash 7 | 8 | echo "[---install-docker.sh Complete---]" 9 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/pkg/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # pkg: 4 | 5 | ## 说明: 6 | 7 | - 本目录, 用于存放与`业务无关`的通用代码 8 | - 常用的 utility, wrap, hook, 中间件等等 9 | - 后期可逐步迁移到外部, 供其他项目使用. 10 | 11 | 12 | ## 区别 app/std 目录: 13 | 14 | - app/std 是`项目内`全局`公共依赖`: 标准状态码, 标准配置 15 | 16 | 17 | ## 目录结构建议: 18 | 19 | - 参考 go 标准库目录组织方式. 20 | 21 | 22 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/std/readme.md: -------------------------------------------------------------------------------- 1 | # std: 2 | 3 | - 项目自身的标准定义: 4 | 5 | - 公共错误码 6 | - 公共配置文件定义格式 7 | - 公共接口参数约定规范 8 | 9 | 10 | 11 | ```bash 12 | 13 | err code: 14 | 15 | config fmt: 16 | 17 | req/resp arg fmt: 18 | 19 | 20 | ``` 21 | 22 | 23 | 24 | ## 生成: 25 | 26 | 27 | ```bash 28 | 29 | 30 | make proto 31 | 32 | ``` -------------------------------------------------------------------------------- /single-app/gin/hooks/post_gen_project.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) 5 | 6 | 7 | def remove_file(filepath): 8 | os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) 9 | 10 | 11 | def single_app_create(): 12 | print("single app create:") 13 | 14 | 15 | if __name__ == '__main__': 16 | single_app_create() 17 | -------------------------------------------------------------------------------- /mono-repo/rs/cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "repo_name": "mono repo name: like [mall]", 3 | "biz_app_name": "biz_app_name: like[chat]", 4 | "project_short_description": "go-zero mono repo project generator.", 5 | "open_source_license": [ 6 | "MIT", 7 | "BSD", 8 | "GPLv3", 9 | "Apache Software License 2.0", 10 | "Not open source" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/deploy/production/templates/install-base.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[---Begin install-base.sh---]" 4 | 5 | echo "Wait for system to be ready" 6 | sleep 10 7 | 8 | echo "Run base script" 9 | curl https://raw.githubusercontent.com/hashicorp/guides-configuration/master/shared/scripts/base.sh | bash 10 | 11 | echo "[---install-base.sh Complete---]" 12 | -------------------------------------------------------------------------------- /single-app/go-zero/hooks/post_gen_project.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) 5 | 6 | 7 | def remove_file(filepath): 8 | os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) 9 | 10 | 11 | def single_app_create(): 12 | print("single app create:") 13 | 14 | 15 | if __name__ == '__main__': 16 | single_app_create() 17 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/deploy/production/templates/install-base.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[---Begin install-base.sh---]" 4 | 5 | echo "Wait for system to be ready" 6 | sleep 10 7 | 8 | echo "Run base script" 9 | curl https://raw.githubusercontent.com/hashicorp/guides-configuration/master/shared/scripts/base.sh | bash 10 | 11 | echo "[---install-base.sh Complete---]" 12 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/deploy/production/templates/install-base.sh.tpl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[---Begin install-base.sh---]" 4 | 5 | echo "Wait for system to be ready" 6 | sleep 10 7 | 8 | echo "Run base script" 9 | curl https://raw.githubusercontent.com/hashicorp/guides-configuration/master/shared/scripts/base.sh | bash 10 | 11 | echo "[---install-base.sh Complete---]" 12 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/basic/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | # app/basic: 5 | 6 | - Basic services 7 | 8 | 9 | ## illustrate: 10 | 11 | - In general business scenarios, public basic services: 12 | - user: register/login/ 13 | - auth: 14 | - permission: 15 | - role: 16 | - vip-account: 17 | - security: 18 | - push: 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/mq/hello_test.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | "time" 7 | ) 8 | 9 | func TestHelloQueue_Publish(t *testing.T) { 10 | // required start rabbitmq before 11 | msg := fmt.Sprintf("unit test pub msg: %v", time.Now()) 12 | err := testDao.Hello.Publish(msg) 13 | t.Logf("mq publish msg: %v, error: %v", msg, err) 14 | } 15 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/basic/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | # app/basic: 5 | 6 | - Basic services 7 | 8 | 9 | ## illustrate: 10 | 11 | - In general business scenarios, public basic services: 12 | - user: register/login/ 13 | - auth: 14 | - permission: 15 | - role: 16 | - vip-account: 17 | - security: 18 | - push: 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | # app/basic: 5 | 6 | - Basic services 7 | 8 | 9 | ## illustrate: 10 | 11 | - In general business scenarios, public basic services: 12 | - user: register/login/ 13 | - auth: 14 | - permission: 15 | - role: 16 | - vip-account: 17 | - security: 18 | - push: 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /mono-repo/go-zero/cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "go_module_name": "mono repo go_module_name(go.mod): like [mall]", 3 | "biz_app_name": "biz_app_name: like[chat]", 4 | "project_short_description": "go-zero mono repo project generator.", 5 | "open_source_license": [ 6 | "MIT", 7 | "BSD", 8 | "GPLv3", 9 | "Apache Software License 2.0", 10 | "Not open source" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/mq/hello_test.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | "time" 7 | ) 8 | 9 | func TestHelloQueue_Publish(t *testing.T) { 10 | // required start rabbitmq before 11 | msg := fmt.Sprintf("unit test pub msg: %v", time.Now()) 12 | err := testDao.Hello.Publish(msg) 13 | t.Logf("mq publish msg: %v, error: %v", msg, err) 14 | } 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | gen.mono.repo: 4 | cd tmp/; cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="mono-repo/go-zero" 5 | 6 | gen.basic.app: 7 | cd tmp/mall/app/basic; cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="single-app/go-zero" 8 | 9 | gen.biz.app: 10 | cd tmp/mall/app/biz; cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="single-app/go-zero" 11 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/deploy/production/terraform-aws/gitignore.tf: -------------------------------------------------------------------------------- 1 | # `.tf` files that contain the word "gitignore" are ignored 2 | # by git in the `.gitignore` file at the root of this repo. 3 | 4 | # If you have local Terraform configuration that you want 5 | # ignored like Terraform backend configuration, create 6 | # a new file (separate from this one) that contains the 7 | # word "gitignore" (e.g. `backend.gitignore.tf`). 8 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | server "github.com/better-go/pkg/x/go-zero/option" 5 | ) 6 | 7 | // 服务启动器: 8 | func NewServerSelector() (server.Server, server.Server, server.Server, server.Server) { 9 | return &InnerServer{}, // gRpc server 10 | &OuterServer{}, // http server 11 | &JobServer{}, // job server 12 | &AdminServer{} // admin server 13 | } 14 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/deploy/production/terraform-aws/gitignore.tf: -------------------------------------------------------------------------------- 1 | # `.tf` files that contain the word "gitignore" are ignored 2 | # by git in the `.gitignore` file at the root of this repo. 3 | 4 | # If you have local Terraform configuration that you want 5 | # ignored like Terraform backend configuration, create 6 | # a new file (separate from this one) that contains the 7 | # word "gitignore" (e.g. `backend.gitignore.tf`). 8 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/deploy/production/terraform-aws/gitignore.tf: -------------------------------------------------------------------------------- 1 | # `.tf` files that contain the word "gitignore" are ignored 2 | # by git in the `.gitignore` file at the root of this repo. 3 | 4 | # If you have local Terraform configuration that you want 5 | # ignored like Terraform backend configuration, create 6 | # a new file (separate from this one) that contains the 7 | # word "gitignore" (e.g. `backend.gitignore.tf`). 8 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/go.mod: -------------------------------------------------------------------------------- 1 | module {{cookiecutter.go_module_name}} 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/better-go/pkg v0.1.15 7 | github.com/gogo/protobuf v1.3.2 8 | github.com/golang/protobuf v1.4.2 9 | github.com/tal-tech/go-zero v1.1.5 10 | go.uber.org/automaxprocs v1.4.0 // indirect 11 | golang.org/x/sys v0.0.0-20210218085108-9555bcde0c6a // indirect 12 | google.golang.org/grpc v1.29.1 13 | ) 14 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/.goreleaser.yml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # 3 | # ref: 4 | # - https://github.com/caddyserver/caddy/blob/master/.goreleaser.yml 5 | # - https://github.com/nats-io/nats-server/blob/master/.goreleaser.yml 6 | # 7 | ################################################################################################################ 8 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "repo_name": "mall", 3 | "biz_app_name": "cart", 4 | "project_short_description": "go-kratos mono repo project generator.", 5 | "author_name": "Henry Huang", 6 | "author_email": "hhglory@outlook.com", 7 | "open_source_license": [ 8 | "MIT", 9 | "BSD", 10 | "GPLv3", 11 | "Apache Software License 2.0", 12 | "Not open source" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/.goreleaser.yml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # 3 | # ref: 4 | # - https://github.com/caddyserver/caddy/blob/master/.goreleaser.yml 5 | # - https://github.com/nats-io/nats-server/blob/master/.goreleaser.yml 6 | # 7 | ################################################################################################################ 8 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | server "github.com/better-go/pkg/x/go-zero/option" 5 | ) 6 | 7 | // 服务启动器: 8 | func NewServerSelector() (server.Server, server.Server, server.Server, server.Server) { 9 | return &InnerServer{}, // gRpc server 10 | &OuterServer{}, // http server 11 | &JobServer{}, // job server 12 | &AdminServer{} // admin server 13 | } 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | charset = utf-8 11 | end_of_line = lf 12 | 13 | [*.bat] 14 | indent_style = tab 15 | end_of_line = crlf 16 | 17 | [LICENSE] 18 | insert_final_newline = false 19 | 20 | [Makefile] 21 | indent_style = tab 22 | 23 | [*.{diff,patch}] 24 | trim_trailing_whitespace = false 25 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/.goreleaser.yml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # 3 | # ref: 4 | # - https://github.com/caddyserver/caddy/blob/master/.goreleaser.yml 5 | # - https://github.com/nats-io/nats-server/blob/master/.goreleaser.yml 6 | # 7 | ################################################################################################################ 8 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/infra/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # infrastructure: 5 | 6 | 7 | - 基础设施: 中间件 8 | 9 | 10 | ## 说明: 11 | 12 | - 项目常用依赖的公共组件服务: 13 | - 服务发现 14 | - 配置中心 15 | - API 网关 16 | - 负载均衡/限流器 17 | - 分布式存储: DB/KV/CACHE/MQ/DFS 18 | - 数据分析平台: BI 19 | - 集成测试: CI 20 | - 发布系统/部署平台: K8S 21 | - 基于开源中间件, 定制化的通用平台服务, 与业务无关 22 | - 自主研发的中间件设施. 23 | - 研发 cli 工具: 24 | - 初始化脚手架 25 | - 代码 check 工具 26 | - sql 漏洞分析工具 27 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/infra/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # infrastructure: 5 | 6 | 7 | - 基础设施: 中间件 8 | 9 | 10 | ## 说明: 11 | 12 | - 项目常用依赖的公共组件服务: 13 | - 服务发现 14 | - 配置中心 15 | - API 网关 16 | - 负载均衡/限流器 17 | - 分布式存储: DB/KV/CACHE/MQ/DFS 18 | - 数据分析平台: BI 19 | - 集成测试: CI 20 | - 发布系统/部署平台: K8S 21 | - 基于开源中间件, 定制化的通用平台服务, 与业务无关 22 | - 自主研发的中间件设施. 23 | - 研发 cli 工具: 24 | - 初始化脚手架 25 | - 代码 check 工具 26 | - sql 漏洞分析工具 27 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/infra/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # infrastructure: 5 | 6 | 7 | - 基础设施: 中间件 8 | 9 | 10 | ## 说明: 11 | 12 | - 项目常用依赖的公共组件服务: 13 | - 服务发现 14 | - 配置中心 15 | - API 网关 16 | - 负载均衡/限流器 17 | - 分布式存储: DB/KV/CACHE/MQ/DFS 18 | - 数据分析平台: BI 19 | - 集成测试: CI 20 | - 发布系统/部署平台: K8S 21 | - 基于开源中间件, 定制化的通用平台服务, 与业务无关 22 | - 自主研发的中间件设施. 23 | - 研发 cli 工具: 24 | - 初始化脚手架 25 | - 代码 check 工具 26 | - sql 漏洞分析工具 27 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/deploy/local/.env.example: -------------------------------------------------------------------------------- 1 | 2 | ##################################################################################### 3 | # 4 | # for docker-compose auto use: 5 | # - https://docs.docker.com/compose/environment-variables/ 6 | # 7 | ##################################################################################### 8 | 9 | 10 | # mac local ip: 11 | ENV_LOCAL_IP=`ifconfig | grep inet | grep -v inet6 | grep -v 127 | cut -d ' ' -f2` 12 | 13 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/proto/api/api_queue.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | type HelloReq struct { 4 | Name string `path:"name"` 5 | } 6 | 7 | // queue message: 8 | type MessageReq struct { 9 | QueueName string `json:"queue_name"` 10 | 11 | Type string `json:"type"` 12 | Data string `json:"data"` 13 | //RawData []byte `json:"raw_data"` 14 | Timestamp int `json:"timestamp"` 15 | } 16 | 17 | // 18 | type MessageResp struct { 19 | Status string `json:"status"` 20 | } 21 | -------------------------------------------------------------------------------- /library-repo/cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "repo_name": "package", 3 | "project_short_description": "a golang package repo generator.", 4 | 5 | 6 | "open_source_license": [ 7 | "MIT", 8 | "BSD", 9 | "GPLv3", 10 | "Apache Software License 2.0", 11 | "Not open source" 12 | ], 13 | "author_name": "Henry", 14 | "email": "hhglory@outlook.com", 15 | "release_date": "2020-06-01", 16 | "year": "2020", 17 | "version": "0.1.0" 18 | } 19 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/Makefile.install.mk: -------------------------------------------------------------------------------- 1 | 2 | ################################################################################################ 3 | 4 | # https://github.com/gogo/protobuf 5 | proto.install: 6 | go get -u -v github.com/gogo/protobuf/protoc-gen-gofast 7 | go get -u -v github.com/gogo/protobuf/proto 8 | go get -u -v github.com/gogo/protobuf/jsonpb 9 | go get -u -v github.com/gogo/protobuf/protoc-gen-gogo 10 | go get -u -v github.com/gogo/protobuf/gogoproto 11 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/db/db.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | ) 6 | 7 | /* 8 | 所有 HTTP 接口对接 9 | 10 | */ 11 | 12 | type Dao struct { 13 | // biz group: 14 | Demo *DemoDB // demo db 15 | } 16 | 17 | func New(cfg *config.DBUnit) *Dao { 18 | return &Dao{ 19 | Demo: newDemoDB(cfg), 20 | } 21 | } 22 | 23 | func (m *Dao) Close() { 24 | return 25 | } 26 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/mq/mq.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | ) 6 | 7 | /* 8 | 所有 HTTP 接口对接 9 | 10 | */ 11 | 12 | type Dao struct { 13 | // biz group: 14 | Demo *DemoMQ // demo http 15 | } 16 | 17 | func New(cfg *config.MQUnit) *Dao { 18 | return &Dao{ 19 | Demo: newDemoMQ(cfg), 20 | } 21 | } 22 | 23 | func (m *Dao) Close() { 24 | return 25 | } 26 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/Makefile.install.mk: -------------------------------------------------------------------------------- 1 | 2 | ################################################################################################ 3 | 4 | # https://github.com/gogo/protobuf 5 | proto.install: 6 | go get -u -v github.com/gogo/protobuf/protoc-gen-gofast 7 | go get -u -v github.com/gogo/protobuf/proto 8 | go get -u -v github.com/gogo/protobuf/jsonpb 9 | go get -u -v github.com/gogo/protobuf/protoc-gen-gogo 10 | go get -u -v github.com/gogo/protobuf/gogoproto 11 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/rpc/rpc.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | ) 6 | 7 | /* 8 | 所有 HTTP 接口对接 9 | 10 | */ 11 | 12 | type Dao struct { 13 | // biz group: 14 | Demo *DemoRpc // demo rpc 15 | } 16 | 17 | func New(cfg *config.RpcUnit) *Dao { 18 | return &Dao{ 19 | Demo: newDemoRpc(cfg), 20 | } 21 | } 22 | 23 | func (m *Dao) Close() { 24 | return 25 | } 26 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/Makefile.install.mk: -------------------------------------------------------------------------------- 1 | 2 | ################################################################################################ 3 | 4 | # https://github.com/gogo/protobuf 5 | proto.install: 6 | go get -u -v github.com/gogo/protobuf/protoc-gen-gofast 7 | go get -u -v github.com/gogo/protobuf/proto 8 | go get -u -v github.com/gogo/protobuf/jsonpb 9 | go get -u -v github.com/gogo/protobuf/protoc-gen-gogo 10 | go get -u -v github.com/gogo/protobuf/gogoproto 11 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/http/http.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | ) 6 | 7 | /* 8 | 所有 HTTP 接口对接 9 | 10 | */ 11 | 12 | type Dao struct { 13 | // biz group: 14 | Demo *DemoHttp // demo http 15 | } 16 | 17 | func New(cfg *config.HttpUnit) *Dao { 18 | return &Dao{ 19 | Demo: newDemoHttp(cfg), 20 | } 21 | } 22 | 23 | func (m *Dao) Close() { 24 | return 25 | } 26 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/proto/api/api_queue.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | type HelloReq struct { 4 | Name string `path:"name"` 5 | } 6 | 7 | // queue message: 8 | type MessageReq struct { 9 | QueueName string `json:"queue_name"` 10 | 11 | Type string `json:"type"` 12 | Data string `json:"data"` 13 | //RawData []byte `json:"raw_data"` 14 | Timestamp int `json:"timestamp"` 15 | } 16 | 17 | // 18 | type MessageResp struct { 19 | Status string `json:"status"` 20 | } 21 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/std/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # std: 3 | 4 | - Standard definition of the project itself: 5 | 6 | - public error code 7 | - Common configuration file definition format 8 | - Public interface parameter convention specification 9 | 10 | 11 | 12 | ```bash 13 | 14 | err code: 15 | 16 | config fmt: 17 | 18 | req/resp arg fmt: 19 | 20 | 21 | ``` 22 | 23 | 24 | 25 | ## Generate: 26 | 27 | 28 | ```bash 29 | 30 | 31 | make proto 32 | 33 | ``` 34 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/cache/cache.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | ) 6 | 7 | /* 8 | 所有 HTTP 接口对接 9 | 10 | */ 11 | 12 | type Dao struct { 13 | // biz group: 14 | Demo *DemoCache // demo cache 15 | } 16 | 17 | func New(cfg *config.CacheUnit) *Dao { 18 | return &Dao{ 19 | Demo: newDemoCache(cfg), 20 | } 21 | } 22 | 23 | func (m *Dao) Close() { 24 | return 25 | } 26 | -------------------------------------------------------------------------------- /mono-repo/gin/hooks/post_gen_project.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) 5 | 6 | 7 | def remove_file(filepath): 8 | os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) 9 | 10 | 11 | def mono_repo_create(): 12 | print("single app create:") 13 | 14 | 15 | if __name__ == '__main__': 16 | mono_repo_create() 17 | 18 | # clean: 19 | if 'Not open source' == '{{ cookiecutter.open_source_license }}': 20 | remove_file('LICENSE') 21 | -------------------------------------------------------------------------------- /mono-repo/rs/hooks/post_gen_project.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) 5 | 6 | 7 | def remove_file(filepath): 8 | os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) 9 | 10 | 11 | def mono_repo_create(): 12 | print("mono repo create:") 13 | 14 | 15 | if __name__ == '__main__': 16 | mono_repo_create() 17 | 18 | # clean: 19 | if 'Not open source' == '{{ cookiecutter.open_source_license }}': 20 | remove_file('LICENSE') 21 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/std/readme.md: -------------------------------------------------------------------------------- 1 | # std: 2 | 3 | - 业务公共统一标准: 出错码/配置/约定 4 | 5 | ## 与 pkg 目录区别: 6 | 7 | - pkg/ 是与业务完全无关, 可以移植到项目外使用的代码 8 | - std/ 是与业务有关, 但是, 是项目全局内, 通用代码 9 | 10 | ## 说明: 11 | 12 | - 项目自身的标准定义: 13 | - 公共错误码 14 | - 公共配置文件定义格式 15 | - 公共接口参数约定规范 16 | 17 | 18 | 19 | ```bash 20 | 21 | err code: 22 | 23 | config fmt: 24 | 25 | req/resp arg fmt: 26 | 27 | 28 | ``` 29 | 30 | 31 | 32 | ## 生成: 33 | 34 | 35 | ```bash 36 | 37 | 38 | make proto 39 | 40 | ``` 41 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/hooks/post_gen_project.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) 5 | 6 | 7 | def remove_file(filepath): 8 | os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) 9 | 10 | 11 | def mono_repo_create(): 12 | print("mono repo create:") 13 | 14 | 15 | if __name__ == '__main__': 16 | mono_repo_create() 17 | 18 | # clean: 19 | if 'Not open source' == '{{ cookiecutter.open_source_license }}': 20 | remove_file('LICENSE') 21 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/std/readme.md: -------------------------------------------------------------------------------- 1 | # std: 2 | 3 | - 业务公共统一标准: 出错码/配置/约定 4 | 5 | ## 与 pkg 目录区别: 6 | 7 | - pkg/ 是与业务完全无关, 可以移植到项目外使用的代码 8 | - std/ 是与业务有关, 但是, 是项目全局内, 通用代码 9 | 10 | ## 说明: 11 | 12 | - 项目自身的标准定义: 13 | - 公共错误码 14 | - 公共配置文件定义格式 15 | - 公共接口参数约定规范 16 | 17 | 18 | 19 | ```bash 20 | 21 | err code: 22 | 23 | config fmt: 24 | 25 | req/resp arg fmt: 26 | 27 | 28 | ``` 29 | 30 | 31 | 32 | ## 生成: 33 | 34 | 35 | ```bash 36 | 37 | 38 | make proto 39 | 40 | ``` 41 | -------------------------------------------------------------------------------- /mono-repo/go-zero/hooks/post_gen_project.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) 5 | 6 | 7 | def remove_file(filepath): 8 | os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) 9 | 10 | 11 | def mono_repo_create(): 12 | print("mono repo create:") 13 | 14 | 15 | if __name__ == '__main__': 16 | mono_repo_create() 17 | 18 | # clean: 19 | if 'Not open source' == '{{ cookiecutter.open_source_license }}': 20 | remove_file('LICENSE') 21 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/std/readme.md: -------------------------------------------------------------------------------- 1 | # std: 2 | 3 | - 业务公共统一标准: 出错码/配置/约定 4 | 5 | ## 与 pkg 目录区别: 6 | 7 | - pkg/ 是与业务完全无关, 可以移植到项目外使用的代码 8 | - std/ 是与业务有关, 但是, 是项目全局内, 通用代码 9 | 10 | ## 说明: 11 | 12 | - 项目自身的标准定义: 13 | - 公共错误码 14 | - 公共配置文件定义格式 15 | - 公共接口参数约定规范 16 | 17 | 18 | 19 | ```bash 20 | 21 | err code: 22 | 23 | config fmt: 24 | 25 | req/resp arg fmt: 26 | 27 | 28 | ``` 29 | 30 | 31 | 32 | ## 生成: 33 | 34 | 35 | ```bash 36 | 37 | 38 | make proto 39 | 40 | ``` 41 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/db/demo.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | 6 | "github.com/better-go/pkg/log" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoDB struct { 11 | } 12 | 13 | func newDemoDB(cfg *config.DBUnit) *DemoDB { 14 | 15 | return &DemoDB{ 16 | } 17 | } 18 | 19 | func (m *DemoDB) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/mq/demo.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | 6 | "github.com/better-go/pkg/log" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoMQ struct { 11 | } 12 | 13 | func newDemoMQ(cfg *config.MQUnit) *DemoMQ { 14 | 15 | return &DemoMQ{ 16 | } 17 | } 18 | 19 | func (m *DemoMQ) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/db/demo.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoDB struct { 11 | } 12 | 13 | func newDemoDB(cfg *config.DBUnit) *DemoDB { 14 | 15 | return &DemoDB{ 16 | } 17 | } 18 | 19 | func (m *DemoDB) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/mq/demo.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoMQ struct { 11 | } 12 | 13 | func newDemoMQ(cfg *config.MQUnit) *DemoMQ { 14 | 15 | return &DemoMQ{ 16 | } 17 | } 18 | 19 | func (m *DemoMQ) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/db/demo.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoDB struct { 11 | } 12 | 13 | func newDemoDB(cfg *config.DBUnit) *DemoDB { 14 | 15 | return &DemoDB{ 16 | } 17 | } 18 | 19 | func (m *DemoDB) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/mq/demo.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoMQ struct { 11 | } 12 | 13 | func newDemoMQ(cfg *config.MQUnit) *DemoMQ { 14 | 15 | return &DemoMQ{ 16 | } 17 | } 18 | 19 | func (m *DemoMQ) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/rpc/demo.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | 6 | "github.com/better-go/pkg/log" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoRpc struct { 11 | } 12 | 13 | func newDemoRpc(cfg *config.RpcUnit) *DemoRpc { 14 | 15 | return &DemoRpc{ 16 | } 17 | } 18 | 19 | func (m *DemoRpc) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/rpc/demo.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | 6 | "github.com/better-go/pkg/log" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoRpc struct { 11 | } 12 | 13 | func newDemoRpc(cfg *config.RpcUnit) *DemoRpc { 14 | 15 | return &DemoRpc{ 16 | } 17 | } 18 | 19 | func (m *DemoRpc) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/.codeclimate.yml: -------------------------------------------------------------------------------- 1 | # 2 | # ref: 3 | # - https://github.com/avelino/awesome-go/blob/master/.codeclimate.yml 4 | # 5 | 6 | --- 7 | engines: 8 | rubocop: 9 | enabled: true 10 | golint: 11 | enabled: true 12 | gofmt: 13 | enabled: true 14 | govet: 15 | enabled: true 16 | fixme: 17 | enabled: true 18 | duplication: 19 | enabled: true 20 | config: 21 | languages: 22 | - go 23 | ratings: 24 | paths: 25 | - "**.go" 26 | exclude_paths: 27 | - vendor/ 28 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/.codeclimate.yml: -------------------------------------------------------------------------------- 1 | # 2 | # ref: 3 | # - https://github.com/avelino/awesome-go/blob/master/.codeclimate.yml 4 | # 5 | 6 | --- 7 | engines: 8 | rubocop: 9 | enabled: true 10 | golint: 11 | enabled: true 12 | gofmt: 13 | enabled: true 14 | govet: 15 | enabled: true 16 | fixme: 17 | enabled: true 18 | duplication: 19 | enabled: true 20 | config: 21 | languages: 22 | - go 23 | ratings: 24 | paths: 25 | - "**.go" 26 | exclude_paths: 27 | - vendor/ 28 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/http/demo.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | 6 | "github.com/better-go/pkg/log" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoHttp struct { 11 | } 12 | 13 | func newDemoHttp(cfg *config.HttpUnit) *DemoHttp { 14 | 15 | return &DemoHttp{ 16 | } 17 | } 18 | 19 | func (m *DemoHttp) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/rpc/demo.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 5 | 6 | "github.com/better-go/pkg/log" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoRpc struct { 11 | } 12 | 13 | func newDemoRpc(cfg *config.RpcUnit) *DemoRpc { 14 | 15 | return &DemoRpc{ 16 | } 17 | } 18 | 19 | func (m *DemoRpc) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/.codeclimate.yml: -------------------------------------------------------------------------------- 1 | # 2 | # ref: 3 | # - https://github.com/avelino/awesome-go/blob/master/.codeclimate.yml 4 | # 5 | 6 | --- 7 | engines: 8 | rubocop: 9 | enabled: true 10 | golint: 11 | enabled: true 12 | gofmt: 13 | enabled: true 14 | govet: 15 | enabled: true 16 | fixme: 17 | enabled: true 18 | duplication: 19 | enabled: true 20 | config: 21 | languages: 22 | - go 23 | ratings: 24 | paths: 25 | - "**.go" 26 | exclude_paths: 27 | - vendor/ 28 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/pkg/x/errors/errors.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package errors; 4 | 5 | option go_package = "github.com/go-kratos/kratos/v2/errors;errors"; 6 | option java_multiple_files = true; 7 | option java_package = "com.github.kratos.errors"; 8 | option objc_class_prefix = "KratosErrors"; 9 | 10 | import "google/protobuf/descriptor.proto"; 11 | 12 | extend google.protobuf.EnumOptions { 13 | int32 default_code = 1108; 14 | } 15 | 16 | extend google.protobuf.EnumValueOptions { 17 | int32 code = 1109; 18 | } -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/.codeclimate.yml: -------------------------------------------------------------------------------- 1 | # 2 | # ref: 3 | # - https://github.com/avelino/awesome-go/blob/master/.codeclimate.yml 4 | # 5 | 6 | --- 7 | engines: 8 | rubocop: 9 | enabled: true 10 | golint: 11 | enabled: true 12 | gofmt: 13 | enabled: true 14 | govet: 15 | enabled: true 16 | fixme: 17 | enabled: true 18 | duplication: 19 | enabled: true 20 | config: 21 | languages: 22 | - go 23 | ratings: 24 | paths: 25 | - "**.go" 26 | exclude_paths: 27 | - vendor/ 28 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/dao/cache/demo.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 5 | 6 | "github.com/better-go/pkg/log" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoCache struct { 11 | } 12 | 13 | func newDemoCache(cfg *config.CacheUnit) *DemoCache { 14 | 15 | return &DemoCache{ 16 | } 17 | } 18 | 19 | func (m *DemoCache) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/cache/demo.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoCache struct { 11 | } 12 | 13 | func newDemoCache(cfg *config.CacheUnit) *DemoCache { 14 | 15 | return &DemoCache{ 16 | } 17 | } 18 | 19 | func (m *DemoCache) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/cache/demo.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 7 | ) 8 | 9 | // 极光推送 API 对接: 10 | type DemoCache struct { 11 | } 12 | 13 | func newDemoCache(cfg *config.CacheUnit) *DemoCache { 14 | 15 | return &DemoCache{ 16 | } 17 | } 18 | 19 | func (m *DemoCache) Hello(message string) error { 20 | log.Debugf("demo.Hello done, req=%+v", message) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/domain/demo/block_test.go: -------------------------------------------------------------------------------- 1 | package queue 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | ) 7 | 8 | func TestBlockScope_CreateMarketEvents(t *testing.T) { 9 | resp, err := testDomain.Block.CreateMarketEvents(context.Background()) 10 | t.Logf("domain test - resp: %+v, err: %v", resp, err) 11 | } 12 | 13 | func TestBlockScope_BlockParse(t *testing.T) { 14 | resp, err := testDomain.Block.BlockParse(context.Background()) 15 | t.Logf("domain test - resp: %+v, err: %v", resp, err) 16 | } 17 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}/block_test.go: -------------------------------------------------------------------------------- 1 | package {{cookiecutter.app_name}} 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | ) 7 | 8 | func TestBlockScope_CreateMarketEvents(t *testing.T) { 9 | resp, err := testDomain.Block.CreateMarketEvents(context.Background()) 10 | t.Logf("domain test - resp: %+v, err: %v", resp, err) 11 | } 12 | 13 | func TestBlockScope_BlockParse(t *testing.T) { 14 | resp, err := testDomain.Block.BlockParse(context.Background()) 15 | t.Logf("domain test - resp: %+v, err: %v", resp, err) 16 | } 17 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/admin/admin.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/domain/demo" 5 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 6 | ) 7 | 8 | /* 9 | Admin API Service: 提供内部 API 10 | 11 | */ 12 | type Service struct { 13 | d *queue.Domain // 引入业务单元 14 | } 15 | 16 | func NewService(cfg config.Config) *Service { 17 | return &Service{ 18 | d: queue.NewDomain(cfg, false), 19 | } 20 | } 21 | 22 | func (m *Service) Close() { 23 | m.d.Close() 24 | } 25 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/api/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # api: 3 | 4 | - API for all services: 5 | - protobuf definition: 6 | 7 | ## Two management options: 8 | 9 | - Centralized management of PROTO API definitions: 10 | - It is convenient for client to call 11 | - Decentralized management PROTO API definition: 12 | - Facilitate development by maintainers of a single service 13 | 14 | ## Compromise: 15 | 16 | - Write a sync script. 17 | - Periodically and automatically synchronize the proto api definitions in each service to the api/ folder. 18 | 19 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/inner/inner.go: -------------------------------------------------------------------------------- 1 | package inner 2 | 3 | import ( 4 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/domain/demo" 5 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 6 | ) 7 | 8 | /* 9 | 内部 RPC Server: 对内提供 gRPC API 10 | 11 | */ 12 | 13 | type Service struct { 14 | d *queue.Domain // 引入业务单元 15 | } 16 | 17 | func NewService(cfg config.Config) *Service { 18 | return &Service{ 19 | d: queue.NewDomain(cfg, true), 20 | } 21 | } 22 | 23 | func (m *Service) Close() { 24 | m.d.Close() 25 | } 26 | -------------------------------------------------------------------------------- /.github/workflows/changelog.yml: -------------------------------------------------------------------------------- 1 | name: Generate changelog 2 | on: 3 | release: 4 | types: [created, edited] 5 | 6 | jobs: 7 | generate-changelog: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | with: 12 | fetch-depth: 0 13 | - uses: BobAnkh/auto-generate-changelog@master 14 | with: 15 | ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}} 16 | PATH: '/CHANGELOG.md' 17 | COMMIT_MESSAGE: 'docs(CHANGELOG): update release notes' 18 | TYPE: 'feat:Feature,fix:Bug Fixes,docs:Documentation,refactor:Refactor,perf:Performance Improvements' 19 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/service/admin/admin.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}" 5 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 6 | ) 7 | 8 | /* 9 | Admin API Service: 提供内部 API 10 | 11 | */ 12 | type Service struct { 13 | d *queue.Domain // 引入业务单元 14 | } 15 | 16 | func NewService(cfg config.Config) *Service { 17 | return &Service{ 18 | d: queue.NewDomain(cfg, false), 19 | } 20 | } 21 | 22 | func (m *Service) Close() { 23 | m.d.Close() 24 | } 25 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/service/inner/inner.go: -------------------------------------------------------------------------------- 1 | package inner 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}" 5 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 6 | ) 7 | 8 | /* 9 | 内部 RPC Server: 对内提供 gRPC API 10 | 11 | */ 12 | 13 | type Service struct { 14 | d *queue.Domain // 引入业务单元 15 | } 16 | 17 | func NewService(cfg config.Config) *Service { 18 | return &Service{ 19 | d: queue.NewDomain(cfg, true), 20 | } 21 | } 22 | 23 | func (m *Service) Close() { 24 | m.d.Close() 25 | } 26 | -------------------------------------------------------------------------------- /single-app/go-zero/cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "app_name": "current_app_name: like (demo)", 3 | "app_relative_path": "project/root/path/to/here: like (mall/app/basic), >> no end / ", 4 | 5 | "framework_type": [ 6 | "go-zero", 7 | "go-micro", 8 | "gin" 9 | ], 10 | "db_type": "mysql", 11 | "orm_type": [ 12 | "gorm", 13 | "xorm" 14 | ], 15 | "cache_type": "redis", 16 | "mq_type": [ 17 | "kafka", 18 | "rabbitmq", 19 | "nsq", 20 | "nat" 21 | ], 22 | "use_grpc": "y", 23 | "use_http": "y", 24 | "version": "0.1.0" 25 | } 26 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/outer/outer.go: -------------------------------------------------------------------------------- 1 | package outer 2 | 3 | import ( 4 | "context" 5 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/domain/demo" 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 7 | ) 8 | 9 | /* 10 | 对外暴露的 API server: HTTP/WebSocket/GraphQL 11 | 12 | */ 13 | type Service struct { 14 | d *queue.Domain // 引入业务单元 15 | } 16 | 17 | func NewService(cfg config.Config, ctx context.Context) *Service { 18 | return &Service{ 19 | d: queue.NewDomain(cfg, false), 20 | } 21 | } 22 | 23 | func (m *Service) Close() { 24 | m.d.Close() 25 | } 26 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/pkg/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | # pkg: 5 | 6 | ## illustrate: 7 | 8 | - This directory is used to store general code that is not related to `business` 9 | - Common utility, wrap, hook, middleware, etc. 10 | - Later, it can be gradually migrated to the outside for use by other projects. 11 | 12 | 13 | ## Distinguish the app/std directory: 14 | 15 | - app/std is a `project` global` public dependency`: standard status code, standard configuration 16 | 17 | 18 | ## Directory structure suggestion: 19 | 20 | - Refer to the go standard library directory organization. 21 | 22 | 23 | -------------------------------------------------------------------------------- /single-app/gin/cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "app_name": "current_app_name", 3 | "repo_name": "repo_folder_name", 4 | "app_go_module_name": "go_mod_name", 5 | "app_relative_path": "project/root/path/to/here", 6 | 7 | 8 | "framework_type": [ 9 | "go-micro", 10 | "gin" 11 | ], 12 | "db_type": "mysql", 13 | "orm_type": [ 14 | "gorm", 15 | "xorm" 16 | ], 17 | "cache_type": "redis", 18 | "mq_type": [ 19 | "kafka", 20 | "rabbitmq", 21 | "nsq", 22 | "nat" 23 | ], 24 | "use_grpc": "y", 25 | "use_http": "y", 26 | "version": "0.1.0" 27 | } 28 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/readme.md: -------------------------------------------------------------------------------- 1 | # client: 2 | 3 | - 客户端 4 | - user: 用户端平台 5 | - admin: 内部管理平台 6 | 7 | > 推荐: 8 | 9 | - 基于 Flutter 实现跨平台方案 10 | - 或者 React + React Native 方案 11 | 12 | ## User Side: 13 | 14 | - 用户侧 15 | - web/ 16 | - h5/ 17 | - admin/ 18 | - mobile/ 19 | - ios/ 20 | - android/ 21 | - desktop/ 22 | - macos/ 23 | - windows/ 24 | - linux/ 25 | 26 | ## Admin Side: 27 | 28 | - 内部平台: 29 | - web/ 30 | - h5/ 31 | - admin/ 32 | - mobile/ 33 | - ios/ 34 | - android/ 35 | - desktop/ 36 | - macos/ 37 | - windows/ 38 | - linux/ 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/pkg/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | # pkg: 5 | 6 | ## illustrate: 7 | 8 | - This directory is used to store general code that is not related to `business` 9 | - Common utility, wrap, hook, middleware, etc. 10 | - Later, it can be gradually migrated to the outside for use by other projects. 11 | 12 | 13 | ## Distinguish the app/std directory: 14 | 15 | - app/std is a `project` global` public dependency`: standard status code, standard configuration 16 | 17 | 18 | ## Directory structure suggestion: 19 | 20 | - Refer to the go standard library directory organization. 21 | 22 | 23 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/pkg/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | # pkg: 5 | 6 | ## illustrate: 7 | 8 | - This directory is used to store general code that is not related to `business` 9 | - Common utility, wrap, hook, middleware, etc. 10 | - Later, it can be gradually migrated to the outside for use by other projects. 11 | 12 | 13 | ## Distinguish the app/std directory: 14 | 15 | - app/std is a `project` global` public dependency`: standard status code, standard configuration 16 | 17 | 18 | ## Directory structure suggestion: 19 | 20 | - Refer to the go standard library directory organization. 21 | 22 | 23 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/db/hello.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/model" 7 | ) 8 | 9 | // 用户登录认证: 10 | type HelloStorage struct { 11 | g *ConnGroup 12 | } 13 | 14 | func newHelloStorage(g *ConnGroup) *HelloStorage { 15 | return &HelloStorage{g: g} 16 | } 17 | 18 | func (m *HelloStorage) Hello(ctx context.Context, req *model.HelloReq) (resp *model.HelloEntity, err error) { 19 | resp = new(model.HelloEntity) 20 | 21 | // todo: need query db here 22 | err = m.g.DB.DB().Where(req).Find(&resp).Error 23 | return resp, err 24 | } 25 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/db/hello.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/model" 7 | ) 8 | 9 | // 用户登录认证: 10 | type HelloStorage struct { 11 | g *ConnGroup 12 | } 13 | 14 | func newHelloStorage(g *ConnGroup) *HelloStorage { 15 | return &HelloStorage{g: g} 16 | } 17 | 18 | func (m *HelloStorage) Hello(ctx context.Context, req *model.HelloReq) (resp *model.HelloEntity, err error) { 19 | resp = new(model.HelloEntity) 20 | 21 | // todo: need query db here 22 | err = m.g.DB.DB().Where(req).Find(&resp).Error 23 | return resp, err 24 | } 25 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/service/outer/outer.go: -------------------------------------------------------------------------------- 1 | package outer 2 | 3 | import ( 4 | "context" 5 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}" 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 7 | ) 8 | 9 | /* 10 | 对外暴露的 API server: HTTP/WebSocket/GraphQL 11 | 12 | */ 13 | type Service struct { 14 | d *queue.Domain // 引入业务单元 15 | } 16 | 17 | func NewService(cfg config.Config, ctx context.Context) *Service { 18 | return &Service{ 19 | d: queue.NewDomain(cfg, false), 20 | } 21 | } 22 | 23 | func (m *Service) Close() { 24 | m.d.Close() 25 | } 26 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ################################################################################################ 3 | # 服务部署: 4 | ################################################################################################ 5 | 6 | # import: 7 | include ./Makefile.dev 8 | include ./Makefile.gen 9 | include ./Makefile.install 10 | 11 | ################################################################################################ 12 | # update requirements: 13 | ################################################################################################ 14 | 15 | # update package: 16 | .PHONY: 17 | go.mod.tidy: 18 | go mod tidy -v 19 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/router/router.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/better-go/pkg/log" 7 | "github.com/tal-tech/go-zero/rest/httpx" 8 | ) 9 | 10 | type ServiceFunc func(r *http.Request) (resp interface{}, err error) 11 | 12 | func HandlerWrap(fn ServiceFunc) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | // biz logic handle: 15 | resp, err := fn(r) 16 | log.Infof("http api: url=%+v, req=%+v, resp=%+v, err=%v", r.RequestURI, r.Form, resp, err) 17 | 18 | // resp: 19 | if err != nil { 20 | httpx.Error(w, err) 21 | } else { 22 | httpx.OkJson(w, resp) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/router/router.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/better-go/pkg/log" 7 | "github.com/tal-tech/go-zero/rest/httpx" 8 | ) 9 | 10 | type ServiceFunc func(r *http.Request) (resp interface{}, err error) 11 | 12 | func HandlerWrap(fn ServiceFunc) http.HandlerFunc { 13 | return func(w http.ResponseWriter, r *http.Request) { 14 | // biz logic handle: 15 | resp, err := fn(r) 16 | log.Infof("http api: url=%+v, req=%+v, resp=%+v, err=%v", r.RequestURI, r.Form, resp, err) 17 | 18 | // resp: 19 | if err != nil { 20 | httpx.Error(w, err) 21 | } else { 22 | httpx.OkJson(w, resp) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/router/v1_admin.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "github.com/tal-tech/go-zero/rest" 5 | "net/http" 6 | 7 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/service/admin" 8 | ) 9 | 10 | // admin API server routes: 11 | func RegisterAdminRoutes(engine *rest.Server, svc *admin.Service) { 12 | // register: 13 | engine.AddRoutes( 14 | []rest.Route{ 15 | // rpc api test: 16 | { 17 | Method: http.MethodGet, 18 | Path: "/admin/api/rpc/test", // query block 19 | Handler: HandlerWrap(func(r *http.Request) (resp interface{}, err error) { 20 | return svc.AdminCall(r) 21 | }), 22 | }, 23 | }, 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /mono-repo/gin/hooks/pre_gen_project.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | # regex: 5 | MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$' 6 | 7 | 8 | def validate_name(regex): 9 | # name list: 10 | names = [ 11 | '{{ cookiecutter.repo_name}}', 12 | ] 13 | 14 | # validate: 15 | for name in names: 16 | if not re.match(regex, name): 17 | print('ERROR: The project name (%s) is not a valid module name. Please do not use a - and use _ instead' % name) 18 | return False 19 | # ok: 20 | return True 21 | 22 | 23 | if __name__ == '__main__': 24 | # validate: 25 | if not validate_name(MODULE_REGEX): 26 | # Exit to cancel project 27 | sys.exit(1) 28 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/router/v1_admin.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "github.com/tal-tech/go-zero/rest" 5 | "net/http" 6 | 7 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/admin" 8 | ) 9 | 10 | // admin API server routes: 11 | func RegisterAdminRoutes(engine *rest.Server, svc *admin.Service) { 12 | // register: 13 | engine.AddRoutes( 14 | []rest.Route{ 15 | // rpc api test: 16 | { 17 | Method: http.MethodGet, 18 | Path: "/admin/api/rpc/test", // query block 19 | Handler: HandlerWrap(func(r *http.Request) (resp interface{}, err error) { 20 | return svc.AdminCall(r) 21 | }), 22 | }, 23 | }, 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /single-app/gin/hooks/pre_gen_project.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | # regex: 5 | MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$' 6 | 7 | 8 | def validate_name(regex): 9 | # name list: 10 | names = [ 11 | '{{ cookiecutter.app_name}}', 12 | ] 13 | 14 | # validate: 15 | for name in names: 16 | if not re.match(regex, name): 17 | print('ERROR: The project name (%s) is not a valid module name. Please do not use a - and use _ instead' % name) 18 | return False 19 | # ok: 20 | return True 21 | 22 | 23 | if __name__ == '__main__': 24 | # validate: 25 | if not validate_name(MODULE_REGEX): 26 | # Exit to cancel project 27 | sys.exit(1) 28 | -------------------------------------------------------------------------------- /single-app/go-zero/hooks/pre_gen_project.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | # regex: 5 | MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$' 6 | 7 | 8 | def validate_name(regex): 9 | # name list: 10 | names = [ 11 | '{{ cookiecutter.app_name}}', 12 | ] 13 | 14 | # validate: 15 | for name in names: 16 | if not re.match(regex, name): 17 | print('ERROR: The project name (%s) is not a valid module name. Please do not use a - and use _ instead' % name) 18 | return False 19 | # ok: 20 | return True 21 | 22 | 23 | if __name__ == '__main__': 24 | # validate: 25 | if not validate_name(MODULE_REGEX): 26 | # Exit to cancel project 27 | sys.exit(1) 28 | -------------------------------------------------------------------------------- /.github/workflows/sync.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/marketplace/actions/fork-sync?version=v1.2.1 2 | # .github/workflows/sync.yml 3 | name: Sync Fork 4 | 5 | on: 6 | push: # push 时触发, 主要是为了测试配置有没有问题 7 | schedule: 8 | - cron: '0 * * * *' # 每小时 0分触发, 对于一些更新不那么频繁的项目可以设置为每天一次, 低碳一点 9 | jobs: 10 | repo-sync: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: TG908/fork-sync@v1.1 14 | with: 15 | github_token: ${{ secrets.GITHUB_TOKEN }} # 这个 token action 会默认配置, 这里只需这样写就行 16 | owner: better-go # fork 上游项目 owner 17 | head: master # fork 上游项目需要同步的分支 18 | base: master # 需要同步到本项目的目标分支 19 | auto_approve: true 20 | -------------------------------------------------------------------------------- /mono-repo/rs/hooks/pre_gen_project.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | # regex: 5 | MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$' 6 | 7 | 8 | def validate_name(regex): 9 | # name list: 10 | names = [ 11 | '{{cookiecutter.go_module_name}}', 12 | '{{cookiecutter.biz_app_name}}', 13 | ] 14 | 15 | # validate: 16 | for name in names: 17 | if not re.match(regex, name): 18 | print('ERROR: The project name (%s) is not a valid module name. Please do not use a - and use _ instead' % name) 19 | return False 20 | # ok: 21 | return True 22 | 23 | 24 | if __name__ == '__main__': 25 | # validate: 26 | if not validate_name(MODULE_REGEX): 27 | # Exit to cancel project 28 | sys.exit(1) 29 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/hooks/pre_gen_project.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | # regex: 5 | MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$' 6 | 7 | 8 | def validate_name(regex): 9 | # name list: 10 | names = [ 11 | '{{cookiecutter.repo_name}}', 12 | '{{cookiecutter.biz_app_name}}', 13 | ] 14 | 15 | # validate: 16 | for name in names: 17 | if not re.match(regex, name): 18 | print('ERROR: The project name (%s) is not a valid module name. Please do not use a - and use _ instead' % name) 19 | return False 20 | # ok: 21 | return True 22 | 23 | 24 | if __name__ == '__main__': 25 | # validate: 26 | if not validate_name(MODULE_REGEX): 27 | # Exit to cancel project 28 | sys.exit(1) 29 | -------------------------------------------------------------------------------- /mono-repo/go-zero/hooks/pre_gen_project.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | 4 | # regex: 5 | MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$' 6 | 7 | 8 | def validate_name(regex): 9 | # name list: 10 | names = [ 11 | '{{cookiecutter.go_module_name}}', 12 | '{{cookiecutter.biz_app_name}}', 13 | ] 14 | 15 | # validate: 16 | for name in names: 17 | if not re.match(regex, name): 18 | print('ERROR: The project name (%s) is not a valid module name. Please do not use a - and use _ instead' % name) 19 | return False 20 | # ok: 21 | return True 22 | 23 | 24 | if __name__ == '__main__': 25 | # validate: 26 | if not validate_name(MODULE_REGEX): 27 | # Exit to cancel project 28 | sys.exit(1) 29 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/client/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # client: 3 | 4 | - Client 5 | - user: client platform 6 | - admin: Internal management platform 7 | 8 | > Recommended: 9 | 10 | - Cross-platform solution based on Flutter 11 | - or React + React Native solution 12 | 13 | ## User Side: 14 | 15 | - User side 16 | - web/ 17 | - huh/ 18 | - admin/ 19 | - mobile/ 20 | - ios/ 21 | - android/ 22 | - desktop/ 23 | - macos/ 24 | - windows/ 25 | - linux/ 26 | 27 | ## Admin Side: 28 | 29 | - Internal platform: 30 | - web/ 31 | - huh/ 32 | - admin/ 33 | - mobile/ 34 | - ios/ 35 | - android/ 36 | - desktop/ 37 | - macos/ 38 | - windows/ 39 | - linux/ 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/service/admin/handler.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/better-go/pkg/log" 7 | "github.com/tal-tech/go-zero/rest/httpx" 8 | 9 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/rpc" 10 | ) 11 | 12 | // rpc api: 13 | func (m *Service) AdminCall(r *http.Request) (resp *rpc.AdminResp, err error) { 14 | // TODO: can not use proto req directly, need fix 15 | var req struct { 16 | From string `json:"from"` 17 | } 18 | if err := httpx.Parse(r, &req); err != nil { 19 | return nil, err 20 | } 21 | 22 | resp, err = m.d.Hello.RPC.AdminCall(&rpc.AdminReq{ 23 | From: req.From, 24 | }) 25 | log.Infof("AdminCall: resp=%+v, err=%v", resp, err) 26 | return 27 | } 28 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/admin/handler.go: -------------------------------------------------------------------------------- 1 | package admin 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/better-go/pkg/log" 7 | "github.com/tal-tech/go-zero/rest/httpx" 8 | 9 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/rpc" 10 | ) 11 | 12 | // rpc api: 13 | func (m *Service) AdminCall(r *http.Request) (resp *rpc.AdminResp, err error) { 14 | // TODO: can not use proto req directly, need fix 15 | var req struct { 16 | From string `json:"from"` 17 | } 18 | if err := httpx.Parse(r, &req); err != nil { 19 | return nil, err 20 | } 21 | 22 | resp, err = m.d.Hello.RPC.AdminCall(&rpc.AdminReq{ 23 | From: req.From, 24 | }) 25 | log.Infof("AdminCall: resp=%+v, err=%v", resp, err) 26 | return 27 | } 28 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}/demo.go: -------------------------------------------------------------------------------- 1 | package {{cookiecutter.app_name}} 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/dao" 7 | 8 | "github.com/better-go/pkg/log" 9 | ) 10 | 11 | // demo: 12 | type DemoScope struct { 13 | *dao.MetaResource 14 | } 15 | 16 | func newDemoScope(g *dao.MetaResource) *DemoScope { 17 | return &DemoScope{g} 18 | } 19 | 20 | ////////////////////////////////////////////////////////////////////////////////////////////////////////// 21 | 22 | // 消息推送: 异步+重试 23 | func (m *DemoScope) Hello(ctx context.Context, message string) error { 24 | log.Infof("domain.Demo.Hello done, req=%+v", message) 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/mq/mq_test.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/better-go/pkg/log" 8 | "github.com/tal-tech/go-zero/core/conf" 9 | 10 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 11 | ) 12 | 13 | var ( 14 | testDao *Dao // for unit test case use 15 | ) 16 | 17 | func TestMain(m *testing.M) { 18 | // default config path: 19 | configFile := "../../../configs/configs.yaml" 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | log.Infof("test dao config: %+v", cfg.MQ) 25 | 26 | // new: 27 | testDao = New(cfg.MQ) 28 | defer testDao.Close() 29 | 30 | if code := m.Run(); code != 0 { 31 | os.Exit(code) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/rpc/rpc.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "github.com/tal-tech/go-zero/zrpc" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 7 | ) 8 | 9 | type Dao struct { 10 | Inner zrpc.Client // own rpc client 11 | Grace zrpc.Client // other rpc client 12 | } 13 | 14 | func New(cfg config.ClientUnit, isRpcServer bool) *Dao { 15 | d := &Dao{ 16 | // TODO: add other rpc client 17 | } 18 | 19 | // check own rpc client: 20 | if !isRpcServer { 21 | d.Inner = zrpc.MustNewClient( 22 | cfg.Inner.RpcClientConf, 23 | ) 24 | } 25 | return d 26 | } 27 | 28 | func (m *Dao) Close() { 29 | if m.Inner != nil { 30 | defer m.Inner.Conn().Close() 31 | } 32 | //defer m.Grace.Conn().Close() 33 | } 34 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/mq/mq_test.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/better-go/pkg/log" 8 | "github.com/tal-tech/go-zero/core/conf" 9 | 10 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 11 | ) 12 | 13 | var ( 14 | testDao *Dao // for unit test case use 15 | ) 16 | 17 | func TestMain(m *testing.M) { 18 | // default config path: 19 | configFile := "../../../configs/configs.yaml" 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | log.Infof("test dao config: %+v", cfg.MQ) 25 | 26 | // new: 27 | testDao = New(cfg.MQ) 28 | defer testDao.Close() 29 | 30 | if code := m.Run(); code != 0 { 31 | os.Exit(code) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/rpc/rpc.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "github.com/tal-tech/go-zero/zrpc" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 7 | ) 8 | 9 | type Dao struct { 10 | Inner zrpc.Client // own rpc client 11 | Grace zrpc.Client // other rpc client 12 | } 13 | 14 | func New(cfg config.ClientUnit, isRpcServer bool) *Dao { 15 | d := &Dao{ 16 | // TODO: add other rpc client 17 | } 18 | 19 | // check own rpc client: 20 | if !isRpcServer { 21 | d.Inner = zrpc.MustNewClient( 22 | cfg.Inner.RpcClientConf, 23 | ) 24 | } 25 | return d 26 | } 27 | 28 | func (m *Dao) Close() { 29 | if m.Inner != nil { 30 | defer m.Inner.Conn().Close() 31 | } 32 | //defer m.Grace.Conn().Close() 33 | } 34 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################################################# 3 | # API测试: 4 | ############################################################################################# 5 | 6 | # 本地运行: 7 | run.local: 8 | go run ./cmd/main.go 9 | 10 | # 自动watch 代码变更, 热加载: 11 | run.auto.reload: 12 | # gin 运行模式: 默认 debug 模式 13 | # export GIN_MODE=release; air # 生产环境 14 | export GIN_MODE=debug; air # 开发环境 15 | 16 | ################################################################################################ 17 | 18 | # 生成项目 API 文档: 19 | gen.swagger.docs: 20 | # swagger docs: 21 | swag init -g ./cmd/main.go 22 | 23 | # 浏览器查看 API 文档: 24 | open.swagger.docs: 25 | open http://127.0.0.1:8080/swagger/index.html 26 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/db/db_test.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/better-go/pkg/log" 8 | "github.com/tal-tech/go-zero/core/conf" 9 | 10 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 11 | ) 12 | 13 | var ( 14 | testDao *Dao // for unit test case use 15 | ) 16 | 17 | func TestMain(m *testing.M) { 18 | // default config path: 19 | configFile := "../../../configs/configs.yaml" 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | log.Infof("test dao config: %+v, %+v", cfg.DB, cfg.Cache) 25 | 26 | // new: 27 | testDao = New(cfg) 28 | defer testDao.Close() 29 | 30 | if code := m.Run(); code != 0 { 31 | os.Exit(code) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/db/db_test.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/better-go/pkg/log" 8 | "github.com/tal-tech/go-zero/core/conf" 9 | 10 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 11 | ) 12 | 13 | var ( 14 | testDao *Dao // for unit test case use 15 | ) 16 | 17 | func TestMain(m *testing.M) { 18 | // default config path: 19 | configFile := "../../../configs/configs.yaml" 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | log.Infof("test dao config: %+v, %+v", cfg.DB, cfg.Cache) 25 | 26 | // new: 27 | testDao = New(cfg) 28 | defer testDao.Close() 29 | 30 | if code := m.Run(); code != 0 { 31 | os.Exit(code) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/graphql/graphql_test.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/better-go/pkg/log" 8 | "github.com/tal-tech/go-zero/core/conf" 9 | 10 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 11 | ) 12 | 13 | var ( 14 | testDao *Dao // for unit test case use 15 | ) 16 | 17 | func TestMain(m *testing.M) { 18 | // default config path: 19 | configFile := "../../../configs/configs.yaml" 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | log.Infof("test dao config: %+v", cfg.GraphQL) 25 | 26 | // new: 27 | testDao = New(cfg.GraphQL) 28 | defer testDao.Close() 29 | 30 | if code := m.Run(); code != 0 { 31 | os.Exit(code) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/graphql/graphql_test.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/better-go/pkg/log" 8 | "github.com/tal-tech/go-zero/core/conf" 9 | 10 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 11 | ) 12 | 13 | var ( 14 | testDao *Dao // for unit test case use 15 | ) 16 | 17 | func TestMain(m *testing.M) { 18 | // default config path: 19 | configFile := "../../../configs/configs.yaml" 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | log.Infof("test dao config: %+v", cfg.GraphQL) 25 | 26 | // new: 27 | testDao = New(cfg.GraphQL) 28 | defer testDao.Close() 29 | 30 | if code := m.Run(); code != 0 { 31 | os.Exit(code) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}.go: -------------------------------------------------------------------------------- 1 | package {{cookiecutter.app_name}} 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/dao" 5 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 6 | ) 7 | 8 | // 推送服务业务逻辑 9 | type Scope struct { 10 | // inner global use: 11 | g *dao.MetaResource 12 | 13 | // biz: 14 | Demo *DemoScope 15 | } 16 | 17 | // 18 | func NewScope(cfg *config.Config) *Scope { 19 | // global: 20 | g := dao.NewMetaResource(cfg) 21 | 22 | return &Scope{ 23 | g: g, 24 | 25 | // biz: 26 | Demo: newDemoScope(g), 27 | } 28 | } 29 | 30 | func (m *Scope) Close() { 31 | m.g.Close() 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/app/basic/user/identity/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################################################# 3 | # API测试: 4 | ############################################################################################# 5 | 6 | # 本地运行: 7 | run.local: 8 | go run ./cmd/main.go 9 | 10 | # 自动watch 代码变更, 热加载: 11 | run.auto.reload: 12 | # gin 运行模式: 默认 debug 模式 13 | # export GIN_MODE=release; air # 生产环境 14 | export GIN_MODE=debug; air # 开发环境 15 | 16 | ################################################################################################ 17 | 18 | # 生成项目 API 文档: 19 | gen.swagger.docs: 20 | # swagger docs: 21 | swag init -g ./cmd/main.go 22 | 23 | # 浏览器查看 API 文档: 24 | open.swagger.docs: 25 | open http://127.0.0.1:8080/swagger/index.html 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[enhancement]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Is your feature request related to a problem? Please describe 11 | 12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when \[...] 13 | 14 | ## Description of the new feature/enhancement 15 | 16 | A clear and concise description of what you want to happen. 17 | 18 | ## Proposed technical implementation details (optional) 19 | 20 | A clear and concise description of any solutions you've considered. 21 | 22 | ## Additional context 23 | 24 | Add any other context or screenshots about the feature request here. 25 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/domain/demo/demo_test.go: -------------------------------------------------------------------------------- 1 | package queue 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/better-go/pkg/log" 8 | "github.com/tal-tech/go-zero/core/conf" 9 | 10 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 11 | ) 12 | 13 | var ( 14 | testDomain *Domain // for unit test case use 15 | ) 16 | 17 | func TestMain(m *testing.M) { 18 | // default config path: 19 | configFile := "../../../configs/configs.yaml" 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | log.Infof("test dao config: %+v", cfg.GraphQL) 25 | 26 | // new: 27 | testDomain = NewDomain(cfg, true) 28 | defer testDomain.Close() 29 | 30 | if code := m.Run(); code != 0 { 31 | os.Exit(code) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/infra/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | 5 | # infrastructure: 6 | 7 | 8 | - Infrastructure: Middleware 9 | 10 | 11 | ## illustrate: 12 | 13 | - Common component services commonly used by the project: 14 | - Service discovery 15 | - Configuration Center 16 | - API Gateway 17 | - Load Balancer/Current Limiter 18 | - Distributed storage: DB/KV/CACHE/MQ/DFS 19 | - Data Analysis Platform: BI 20 | - Integration Test: CI 21 | - Release system/deployment platform: K8S 22 | - Based on open source middleware, customized general platform services, independent of business 23 | - Self-developed middleware facilities. 24 | - R&D cli tool: 25 | - Initialize scaffolding 26 | - Code check tool 27 | - sql vulnerability analysis tool 28 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/infra/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | 5 | # infrastructure: 6 | 7 | 8 | - Infrastructure: Middleware 9 | 10 | 11 | ## illustrate: 12 | 13 | - Common component services commonly used by the project: 14 | - Service discovery 15 | - Configuration Center 16 | - API Gateway 17 | - Load Balancer/Current Limiter 18 | - Distributed storage: DB/KV/CACHE/MQ/DFS 19 | - Data Analysis Platform: BI 20 | - Integration Test: CI 21 | - Release system/deployment platform: K8S 22 | - Based on open source middleware, customized general platform services, independent of business 23 | - Self-developed middleware facilities. 24 | - R&D cli tool: 25 | - Initialize scaffolding 26 | - Code check tool 27 | - sql vulnerability analysis tool 28 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/infra/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | 3 | 4 | 5 | # infrastructure: 6 | 7 | 8 | - Infrastructure: Middleware 9 | 10 | 11 | ## illustrate: 12 | 13 | - Common component services commonly used by the project: 14 | - Service discovery 15 | - Configuration Center 16 | - API Gateway 17 | - Load Balancer/Current Limiter 18 | - Distributed storage: DB/KV/CACHE/MQ/DFS 19 | - Data Analysis Platform: BI 20 | - Integration Test: CI 21 | - Release system/deployment platform: K8S 22 | - Based on open source middleware, customized general platform services, independent of business 23 | - Self-developed middleware facilities. 24 | - R&D cli tool: 25 | - Initialize scaffolding 26 | - Code check tool 27 | - sql vulnerability analysis tool 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Dependency directories (remove the comment below to include it) 15 | # vendor/ 16 | 17 | ################################################################################################################ 18 | 19 | # macOS 20 | .DS_Store 21 | 22 | # IDE: Goland 23 | .idea/ 24 | 25 | # IDE: VS Code 26 | .vscode/ 27 | .history/ 28 | 29 | # go mod 30 | vendor/ 31 | 32 | bin/ 33 | tmp/ 34 | *.log 35 | *.pb.go 36 | *.pb.micro.go 37 | .env* 38 | 39 | # artifacts from pprof tooling 40 | *.prof 41 | 42 | # goreleaser artifacts 43 | dist/ 44 | translate_all_readme.sh 45 | format_lines.py 46 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/.pre-commit-hooks.yml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # ref: 3 | # - create hook: https://pre-commit.com/#creating-new-hooks 4 | # - https://github.com/golangci/golangci-lint/blob/master/.pre-commit-hooks.yaml 5 | # - https://github.com/TekWizely/pre-commit-golang 6 | # - https://github.com/Bahjat/pre-commit-golang 7 | # - https://github.com/dnephin/pre-commit-golang 8 | ################################################################################################################ 9 | 10 | 11 | # go lint: 12 | - id: golangci-lint 13 | name: golangci-lint 14 | description: Fast linters runner for Go. 15 | entry: golangci-lint run --fix 16 | types: [go] 17 | language: golang 18 | pass_filenames: false 19 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/.pre-commit-hooks.yaml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # ref: 3 | # - create hook: https://pre-commit.com/#creating-new-hooks 4 | # - https://github.com/golangci/golangci-lint/blob/master/.pre-commit-hooks.yaml 5 | # - https://github.com/TekWizely/pre-commit-golang 6 | # - https://github.com/Bahjat/pre-commit-golang 7 | # - https://github.com/dnephin/pre-commit-golang 8 | ################################################################################################################ 9 | 10 | 11 | # go lint: 12 | - id: golangci-lint 13 | name: golangci-lint 14 | description: Fast linters runner for Go. 15 | entry: golangci-lint run --fix 16 | types: [go] 17 | language: golang 18 | pass_filenames: false 19 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/.pre-commit-hooks.yml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # ref: 3 | # - create hook: https://pre-commit.com/#creating-new-hooks 4 | # - https://github.com/golangci/golangci-lint/blob/master/.pre-commit-hooks.yaml 5 | # - https://github.com/TekWizely/pre-commit-golang 6 | # - https://github.com/Bahjat/pre-commit-golang 7 | # - https://github.com/dnephin/pre-commit-golang 8 | ################################################################################################################ 9 | 10 | 11 | # go lint: 12 | - id: golangci-lint 13 | name: golangci-lint 14 | description: Fast linters runner for Go. 15 | entry: golangci-lint run --fix 16 | types: [go] 17 | language: golang 18 | pass_filenames: false 19 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/.pre-commit-hooks.yaml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # ref: 3 | # - create hook: https://pre-commit.com/#creating-new-hooks 4 | # - https://github.com/golangci/golangci-lint/blob/master/.pre-commit-hooks.yaml 5 | # - https://github.com/TekWizely/pre-commit-golang 6 | # - https://github.com/Bahjat/pre-commit-golang 7 | # - https://github.com/dnephin/pre-commit-golang 8 | ################################################################################################################ 9 | 10 | 11 | # go lint: 12 | - id: golangci-lint 13 | name: golangci-lint 14 | description: Fast linters runner for Go. 15 | entry: golangci-lint run --fix 16 | types: [go] 17 | language: golang 18 | pass_filenames: false 19 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/app/std/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # std: 3 | 4 | - Common unified standard for business: error code/configuration/convention 5 | 6 | ## Difference from pkg directory: 7 | 8 | - pkg/ is completely unrelated to business and can be ported to code used outside the project 9 | - std/ is business-related, however, is a project-wide, general-purpose code 10 | 11 | ## illustrate: 12 | 13 | - Standard definition of the project itself: 14 | - public error code 15 | - Common configuration file definition format 16 | - Public interface parameter convention specification 17 | 18 | 19 | 20 | ```bash 21 | 22 | err code: 23 | 24 | config fmt: 25 | 26 | req/resp arg fmt: 27 | 28 | 29 | ``` 30 | 31 | 32 | 33 | ## Generate: 34 | 35 | 36 | ```bash 37 | 38 | 39 | make proto 40 | 41 | ``` 42 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/app/std/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # std: 3 | 4 | - Common unified standard for business: error code/configuration/convention 5 | 6 | ## Difference from pkg directory: 7 | 8 | - pkg/ is completely unrelated to business and can be ported to code used outside the project 9 | - std/ is business-related, however, is a project-wide, general-purpose code 10 | 11 | ## illustrate: 12 | 13 | - Standard definition of the project itself: 14 | - public error code 15 | - Common configuration file definition format 16 | - Public interface parameter convention specification 17 | 18 | 19 | 20 | ```bash 21 | 22 | err code: 23 | 24 | config fmt: 25 | 26 | req/resp arg fmt: 27 | 28 | 29 | ``` 30 | 31 | 32 | 33 | ## Generate: 34 | 35 | 36 | ```bash 37 | 38 | 39 | make proto 40 | 41 | ``` 42 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/std/readme-en.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](readme.md) 2 | # std: 3 | 4 | - Common unified standard for business: error code/configuration/convention 5 | 6 | ## Difference from pkg directory: 7 | 8 | - pkg/ is completely unrelated to business and can be ported to code used outside the project 9 | - std/ is business-related, however, is a project-wide, general-purpose code 10 | 11 | ## illustrate: 12 | 13 | - Standard definition of the project itself: 14 | - public error code 15 | - Common configuration file definition format 16 | - Public interface parameter convention specification 17 | 18 | 19 | 20 | ```bash 21 | 22 | err code: 23 | 24 | config fmt: 25 | 26 | req/resp arg fmt: 27 | 28 | 29 | ``` 30 | 31 | 32 | 33 | ## Generate: 34 | 35 | 36 | ```bash 37 | 38 | 39 | make proto 40 | 41 | ``` 42 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/domain/demo/hello.go: -------------------------------------------------------------------------------- 1 | package queue 2 | 3 | import ( 4 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao" 5 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/api" 6 | ) 7 | 8 | // demo: 9 | type HelloScope struct { 10 | *dao.MetaResource 11 | } 12 | 13 | func newAuthScope(g *dao.MetaResource) *HelloScope { 14 | return &HelloScope{g} 15 | } 16 | 17 | // one api: 18 | func (m *HelloScope) Demo(req api.HelloReq) (*api.Response, error) { 19 | // todo: add your logic here and delete this line 20 | return &api.Response{ 21 | Message: "hello " + req.Name, 22 | }, nil 23 | } 24 | 25 | // one api: 26 | func (m *HelloScope) Publish(req api.MessageReq) (resp *api.MessageResp, err error) { 27 | resp = new(api.MessageResp) 28 | 29 | err = m.MQ.Hello.Publish(req.Data) 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}_test.go: -------------------------------------------------------------------------------- 1 | package {{cookiecutter.app_name}} 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/better-go/pkg/log" 8 | "github.com/tal-tech/go-zero/core/conf" 9 | 10 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 11 | ) 12 | 13 | var ( 14 | testDomain *Domain // for unit test case use 15 | ) 16 | 17 | func TestMain(m *testing.M) { 18 | // default config path: 19 | configFile := "../../../configs/configs.yaml" 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | log.Infof("test dao config: %+v", cfg.GraphQL) 25 | 26 | // new: 27 | testDomain = NewDomain(cfg, true) 28 | defer testDomain.Close() 29 | 30 | if code := m.Run(); code != 0 { 31 | os.Exit(code) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/deploy/local/infra-mq-rabbitmq.yml: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # portainer service: 3 | # 4 | # ref: 5 | # - https://docs.docker.com/compose/compose-file/ 6 | # - https://github.com/micahhausler/rabbitmq-compose/blob/master/docker-compose.yml 7 | 8 | ########################################################################################## 9 | 10 | version: "3.3" 11 | 12 | services: 13 | rabbitmq: 14 | image: rabbitmq:3-management 15 | container_name: rabbitmq 16 | hostname: "rabbit" 17 | environment: 18 | # vhost: 19 | RABBITMQ_DEFAULT_VHOST: "exchange_server" 20 | # user: 21 | RABBITMQ_DEFAULT_USER: "rabbit" 22 | RABBITMQ_DEFAULT_PASS: "rabbit" 23 | ports: 24 | - "15672:15672" 25 | - "5672:5672" 26 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/deploy/local/infra-mq-rabbitmq.yml: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # portainer service: 3 | # 4 | # ref: 5 | # - https://docs.docker.com/compose/compose-file/ 6 | # - https://github.com/micahhausler/rabbitmq-compose/blob/master/docker-compose.yml 7 | 8 | ########################################################################################## 9 | 10 | version: "3.3" 11 | 12 | services: 13 | rabbitmq: 14 | image: rabbitmq:3-management 15 | container_name: rabbitmq 16 | hostname: "rabbit" 17 | environment: 18 | # vhost: 19 | RABBITMQ_DEFAULT_VHOST: "exchange_server" 20 | # user: 21 | RABBITMQ_DEFAULT_USER: "rabbit" 22 | RABBITMQ_DEFAULT_PASS: "rabbit" 23 | ports: 24 | - "15672:15672" 25 | - "5672:5672" 26 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/deploy/local/infra-mq-rabbitmq.yml: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # portainer service: 3 | # 4 | # ref: 5 | # - https://docs.docker.com/compose/compose-file/ 6 | # - https://github.com/micahhausler/rabbitmq-compose/blob/master/docker-compose.yml 7 | 8 | ########################################################################################## 9 | 10 | version: "3.3" 11 | 12 | services: 13 | rabbitmq: 14 | image: rabbitmq:3-management 15 | container_name: rabbitmq 16 | hostname: "rabbit" 17 | environment: 18 | # vhost: 19 | RABBITMQ_DEFAULT_VHOST: "exchange_server" 20 | # user: 21 | RABBITMQ_DEFAULT_USER: "rabbit" 22 | RABBITMQ_DEFAULT_PASS: "rabbit" 23 | ports: 24 | - "15672:15672" 25 | - "5672:5672" 26 | -------------------------------------------------------------------------------- /.github/workflows/contributors.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | # 3 | # ref: 4 | # - https://github.com/BobAnkh/add-contributors/blob/master/.github/workflows/contributors.yml 5 | # 6 | 7 | name: Add contributors 8 | on: 9 | #schedule: 10 | # - cron: '20 20 * * *' 11 | push: 12 | branches: 13 | - master 14 | 15 | jobs: 16 | add-contributors: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: BobAnkh/add-contributors@master 21 | with: 22 | CONTRIBUTOR: '## Contributors:' # TODO X: reset here! 23 | COLUMN_PER_ROW: '6' 24 | ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}} 25 | IMG_WIDTH: '100' 26 | FONT_SIZE: '14' 27 | PATH: '/readme.md' # TODO X: check here! 28 | COMMIT_MESSAGE: 'docs(README): update contributors' 29 | AVATAR_SHAPE: 'round' 30 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/rpc/inner.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/rpc" 7 | ) 8 | 9 | // 10 | func (m *Dao) Graceful() (resp *rpc.Response, err error) { 11 | // rpc conn: 12 | conn := m.Inner.Conn() 13 | cli := rpc.NewQueueServiceClient(conn) 14 | 15 | return cli.Grace(context.Background(), &rpc.Request{From: "test"}) 16 | } 17 | 18 | func (m *Dao) RestCall(req *rpc.RestReq) (resp *rpc.RestResp, err error) { 19 | // rpc conn: 20 | conn := m.Inner.Conn() 21 | cli := rpc.NewQueueServiceClient(conn) 22 | return cli.RestCall(context.Background(), req) 23 | } 24 | 25 | func (m *Dao) AdminCall(req *rpc.AdminReq) (resp *rpc.AdminResp, err error) { 26 | // rpc conn: 27 | conn := m.Inner.Conn() 28 | cli := rpc.NewQueueServiceClient(conn) 29 | return cli.AdminCall(context.Background(), req) 30 | } 31 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}/hello.go: -------------------------------------------------------------------------------- 1 | package {{cookiecutter.app_name}} 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/dao" 5 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/api" 6 | ) 7 | 8 | // demo: 9 | type HelloScope struct { 10 | *dao.MetaResource 11 | } 12 | 13 | func newAuthScope(g *dao.MetaResource) *HelloScope { 14 | return &HelloScope{g} 15 | } 16 | 17 | // one api: 18 | func (m *HelloScope) Demo(req api.HelloReq) (*api.Response, error) { 19 | // todo: add your logic here and delete this line 20 | return &api.Response{ 21 | Message: "hello " + req.Name, 22 | }, nil 23 | } 24 | 25 | // one api: 26 | func (m *HelloScope) Publish(req api.MessageReq) (resp *api.MessageResp, err error) { 27 | resp = new(api.MessageResp) 28 | 29 | err = m.MQ.Hello.Publish(req.Data) 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/rpc/inner.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/rpc" 7 | ) 8 | 9 | // 10 | func (m *Dao) Graceful() (resp *rpc.Response, err error) { 11 | // rpc conn: 12 | conn := m.Inner.Conn() 13 | cli := rpc.NewQueueServiceClient(conn) 14 | 15 | return cli.Grace(context.Background(), &rpc.Request{From: "test"}) 16 | } 17 | 18 | func (m *Dao) RestCall(req *rpc.RestReq) (resp *rpc.RestResp, err error) { 19 | // rpc conn: 20 | conn := m.Inner.Conn() 21 | cli := rpc.NewQueueServiceClient(conn) 22 | return cli.RestCall(context.Background(), req) 23 | } 24 | 25 | func (m *Dao) AdminCall(req *rpc.AdminReq) (resp *rpc.AdminResp, err error) { 26 | // rpc conn: 27 | conn := m.Inner.Conn() 28 | cli := rpc.NewQueueServiceClient(conn) 29 | return cli.AdminCall(context.Background(), req) 30 | } 31 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/domain/demo/demo.go: -------------------------------------------------------------------------------- 1 | package queue 2 | 3 | import ( 4 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao" 5 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 6 | ) 7 | 8 | /* 9 | 一个业务单元聚合: 10 | - 聚合一堆业务逻辑: 所有业务层的 logic, 都在此层, 与 dao 层区别 11 | - g: 公共数据资源对象, 包含数据层所有可操作资源 12 | - bizScope list: 根据业务拆分的单元, 聚合相关 biz logic 13 | */ 14 | type Domain struct { 15 | // inner global use: 16 | g *dao.MetaResource 17 | 18 | // biz: 19 | Hello *HelloScope 20 | Block *BlockScope 21 | } 22 | 23 | // 24 | func NewDomain(cfg config.Config, isRpcServer bool) *Domain { 25 | // global: 26 | g := dao.NewMetaResource(cfg, isRpcServer) 27 | 28 | return &Domain{ 29 | g: g, 30 | 31 | // biz: 32 | Hello: newAuthScope(g), 33 | Block: newBlockScope(g), 34 | } 35 | } 36 | 37 | func (m *Domain) Close() { 38 | m.g.Close() 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/graphql/chain.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/model/graphql" 7 | ) 8 | 9 | // 链出块分析: 10 | type ChainGraph struct { 11 | g *ConnGroup 12 | } 13 | 14 | func newChainGraph(g *ConnGroup) *ChainGraph { 15 | return &ChainGraph{g: g} 16 | } 17 | 18 | // 19 | func (m *ChainGraph) Block(ctx context.Context, query *graphql.Query) error { 20 | return m.g.cli.Query(ctx, &query, nil) 21 | } 22 | 23 | // market create: 24 | func (m *ChainGraph) CreateMarketEvents(ctx context.Context, query *graphql.QueryCreateMarketEvents) error { 25 | return m.g.cli.Query(ctx, &query, nil) 26 | } 27 | 28 | // QueryFinalizeMarketEvents 29 | func (m *ChainGraph) FinalizeMarketEvents(ctx context.Context, query *graphql.QueryFinalizeMarketEvents) error { 30 | return m.g.cli.Query(ctx, &query, nil) 31 | } 32 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/graphql/chain.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/model/graphql" 7 | ) 8 | 9 | // 链出块分析: 10 | type ChainGraph struct { 11 | g *ConnGroup 12 | } 13 | 14 | func newChainGraph(g *ConnGroup) *ChainGraph { 15 | return &ChainGraph{g: g} 16 | } 17 | 18 | // 19 | func (m *ChainGraph) Block(ctx context.Context, query *graphql.Query) error { 20 | return m.g.cli.Query(ctx, &query, nil) 21 | } 22 | 23 | // market create: 24 | func (m *ChainGraph) CreateMarketEvents(ctx context.Context, query *graphql.QueryCreateMarketEvents) error { 25 | return m.g.cli.Query(ctx, &query, nil) 26 | } 27 | 28 | // QueryFinalizeMarketEvents 29 | func (m *ChainGraph) FinalizeMarketEvents(ctx context.Context, query *graphql.QueryFinalizeMarketEvents) error { 30 | return m.g.cli.Query(ctx, &query, nil) 31 | } 32 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/graphql/chain_test.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/model/graphql" 8 | ) 9 | 10 | func TestChainGraph_Block(t *testing.T) { 11 | var qs graphql.Query 12 | 13 | err := testDao.Chain.Block(context.Background(), &qs) 14 | t.Logf("graphql query resp: %v, err: %v", qs, err) 15 | } 16 | 17 | func TestChainGraph_CreateMarketEvents(t *testing.T) { 18 | var qs graphql.QueryCreateMarketEvents 19 | 20 | err := testDao.Chain.CreateMarketEvents(context.Background(), &qs) 21 | t.Logf("graphql query resp: %v, err: %v", qs, err) 22 | } 23 | 24 | func TestChainGraph_FinalizeMarketEvents(t *testing.T) { 25 | var qs graphql.QueryFinalizeMarketEvents 26 | 27 | err := testDao.Chain.FinalizeMarketEvents(context.Background(), &qs) 28 | t.Logf("graphql query resp: %v, err: %v", qs, err) 29 | } 30 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/graphql/chain_test.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/model/graphql" 8 | ) 9 | 10 | func TestChainGraph_Block(t *testing.T) { 11 | var qs graphql.Query 12 | 13 | err := testDao.Chain.Block(context.Background(), &qs) 14 | t.Logf("graphql query resp: %v, err: %v", qs, err) 15 | } 16 | 17 | func TestChainGraph_CreateMarketEvents(t *testing.T) { 18 | var qs graphql.QueryCreateMarketEvents 19 | 20 | err := testDao.Chain.CreateMarketEvents(context.Background(), &qs) 21 | t.Logf("graphql query resp: %v, err: %v", qs, err) 22 | } 23 | 24 | func TestChainGraph_FinalizeMarketEvents(t *testing.T) { 25 | var qs graphql.QueryFinalizeMarketEvents 26 | 27 | err := testDao.Chain.FinalizeMarketEvents(context.Background(), &qs) 28 | t.Logf("graphql query resp: %v, err: %v", qs, err) 29 | } 30 | -------------------------------------------------------------------------------- /mono-repo/gin/cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "repo_name": "mono", 3 | "basic_app_name": "basic_app", 4 | "biz_app_name": "biz_app", 5 | "project_short_description": "mono repo project generator.", 6 | 7 | 8 | "framework_type": [ 9 | "go-micro", 10 | "gin" 11 | ], 12 | "db_type": "mysql", 13 | "orm_type": [ 14 | "gorm", 15 | "xorm" 16 | ], 17 | "cache_type": "redis", 18 | "mq_type": [ 19 | "kafka", 20 | "rabbitmq", 21 | "nsq", 22 | "nat" 23 | ], 24 | "use_grpc": "y", 25 | "use_http": "y", 26 | "timezone": "UTC", 27 | "open_source_license": [ 28 | "MIT", 29 | "BSD", 30 | "GPLv3", 31 | "Apache Software License 2.0", 32 | "Not open source" 33 | ], 34 | "author_name": "Henry", 35 | "email": "hhglory@outlook.com", 36 | "release_date": "2020-06-01", 37 | "year": "2020", 38 | "version": "0.1.0" 39 | } 40 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}.go: -------------------------------------------------------------------------------- 1 | package {{cookiecutter.app_name}} 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/dao" 5 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 6 | ) 7 | 8 | /* 9 | 一个业务单元聚合: 10 | - 聚合一堆业务逻辑: 所有业务层的 logic, 都在此层, 与 dao 层区别 11 | - g: 公共数据资源对象, 包含数据层所有可操作资源 12 | - bizScope list: 根据业务拆分的单元, 聚合相关 biz logic 13 | */ 14 | type Domain struct { 15 | // inner global use: 16 | g *dao.MetaResource 17 | 18 | // biz: 19 | Hello *HelloScope 20 | Block *BlockScope 21 | } 22 | 23 | // 24 | func NewDomain(cfg config.Config, isRpcServer bool) *Domain { 25 | // global: 26 | g := dao.NewMetaResource(cfg, isRpcServer) 27 | 28 | return &Domain{ 29 | g: g, 30 | 31 | // biz: 32 | Hello: newAuthScope(g), 33 | Block: newBlockScope(g), 34 | } 35 | } 36 | 37 | func (m *Domain) Close() { 38 | m.g.Close() 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/server/job.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | "github.com/better-go/pkg/log" 6 | "github.com/tal-tech/go-zero/core/conf" 7 | "github.com/tal-tech/go-zero/rest" 8 | 9 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/job" 10 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 11 | ) 12 | 13 | // internal job task server: 14 | type JobServer struct{} 15 | 16 | func (m *JobServer) Run(configFile string) { 17 | ctx := context.Background() 18 | 19 | // parse config: 20 | var cfg config.Config 21 | conf.MustLoad(configFile, &cfg) 22 | 23 | // new biz service: 24 | svc := job.NewService(cfg, ctx) 25 | defer svc.Close() 26 | 27 | // run job: 28 | svc.RunAsync() 29 | 30 | // new engine: 31 | engine := rest.MustNewServer(cfg.Server.Job.RestConf) 32 | defer engine.Stop() 33 | 34 | log.Infof("starting job engine at %v\n", cfg.Server.Job.RestConf) 35 | engine.Start() 36 | } 37 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/server/job.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | "github.com/better-go/pkg/log" 6 | "github.com/tal-tech/go-zero/core/conf" 7 | "github.com/tal-tech/go-zero/rest" 8 | 9 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/service/job" 10 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 11 | ) 12 | 13 | // internal job task server: 14 | type JobServer struct{} 15 | 16 | func (m *JobServer) Run(configFile string) { 17 | ctx := context.Background() 18 | 19 | // parse config: 20 | var cfg config.Config 21 | conf.MustLoad(configFile, &cfg) 22 | 23 | // new biz service: 24 | svc := job.NewService(cfg, ctx) 25 | defer svc.Close() 26 | 27 | // run job: 28 | svc.RunAsync() 29 | 30 | // new engine: 31 | engine := rest.MustNewServer(cfg.Server.Job.RestConf) 32 | defer engine.Stop() 33 | 34 | log.Infof("starting job engine at %v\n", cfg.Server.Job.RestConf) 35 | engine.Start() 36 | } 37 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/proto/model/hello.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import "github.com/better-go/pkg/database/orm" 4 | 5 | type HelloEntity struct { 6 | } 7 | 8 | type HelloReq struct { 9 | } 10 | 11 | type HelloResp struct { 12 | } 13 | 14 | // 用户 Meta 信息 15 | type UserMeta struct { 16 | orm.StatusModel 17 | 18 | UserID uint64 `gorm:"UNIQUE; type:BIGINT(20) unsigned; NOT NULL; DEFAULT:'0'; COMMENT:'用户 ID'; "` // 用户 ID 19 | UniqueName string `gorm:"index; type:varchar(128) CHARACTER SET utf8mb4; DEFAULT:''; COMMENT:'方案1:唯一昵称'; "` // 二选一方案: 唯一昵称, 不允许重名 20 | NickName string `gorm:"index; type:varchar(128) CHARACTER SET utf8mb4; DEFAULT:''; COMMENT:'方案2:昵称+编号'; "` // 二选一方案: 昵称 + 昵称编号 21 | NickNo int64 `gorm:"index; type:varchar(128) CHARACTER SET utf8mb4; DEFAULT:''; COMMENT:'方案2:昵称+编号'; "` // 二选一方案: 昵称编号 22 | // auth: 23 | Register string 24 | MobileNo string // 手机号 25 | MobileCode string // 手机号国家码 26 | Email string // 邮箱 27 | Password string // 密码 28 | } 29 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/graphql/graphql.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "github.com/better-go/pkg/net/graphql" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 7 | ) 8 | 9 | type Dao struct { 10 | g *ConnGroup 11 | 12 | // biz: 13 | Chain *ChainGraph 14 | } 15 | 16 | func New(cfg config.GraphQLUnit) *Dao { 17 | // mq meta: 18 | g := newConnGroup(cfg) 19 | 20 | return &Dao{ 21 | g: g, 22 | 23 | // biz: 24 | Chain: newChainGraph(g), 25 | } 26 | } 27 | 28 | func (m *Dao) Close() { 29 | m.g.Close() 30 | return 31 | } 32 | 33 | ////////////////////////////////////////////////////////////////////////////////////////// 34 | 35 | // queue conn: 36 | type ConnGroup struct { 37 | cli *graphql.Client 38 | } 39 | 40 | func newConnGroup(cfg config.GraphQLUnit) *ConnGroup { 41 | cli := graphql.NewClient(cfg.Url, nil) 42 | 43 | return &ConnGroup{ 44 | cli: cli, 45 | } 46 | } 47 | 48 | func (m *ConnGroup) Close() { 49 | return 50 | } 51 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/graphql/graphql.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "github.com/better-go/pkg/net/graphql" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 7 | ) 8 | 9 | type Dao struct { 10 | g *ConnGroup 11 | 12 | // biz: 13 | Chain *ChainGraph 14 | } 15 | 16 | func New(cfg config.GraphQLUnit) *Dao { 17 | // mq meta: 18 | g := newConnGroup(cfg) 19 | 20 | return &Dao{ 21 | g: g, 22 | 23 | // biz: 24 | Chain: newChainGraph(g), 25 | } 26 | } 27 | 28 | func (m *Dao) Close() { 29 | m.g.Close() 30 | return 31 | } 32 | 33 | ////////////////////////////////////////////////////////////////////////////////////////// 34 | 35 | // queue conn: 36 | type ConnGroup struct { 37 | cli *graphql.Client 38 | } 39 | 40 | func newConnGroup(cfg config.GraphQLUnit) *ConnGroup { 41 | cli := graphql.NewClient(cfg.Url, nil) 42 | 43 | return &ConnGroup{ 44 | cli: cli, 45 | } 46 | } 47 | 48 | func (m *ConnGroup) Close() { 49 | return 50 | } 51 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/proto/model/hello.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import "github.com/better-go/pkg/database/orm" 4 | 5 | type HelloEntity struct { 6 | } 7 | 8 | type HelloReq struct { 9 | } 10 | 11 | type HelloResp struct { 12 | } 13 | 14 | // 用户 Meta 信息 15 | type UserMeta struct { 16 | orm.StatusModel 17 | 18 | UserID uint64 `gorm:"UNIQUE; type:BIGINT(20) unsigned; NOT NULL; DEFAULT:'0'; COMMENT:'用户 ID'; "` // 用户 ID 19 | UniqueName string `gorm:"index; type:varchar(128) CHARACTER SET utf8mb4; DEFAULT:''; COMMENT:'方案1:唯一昵称'; "` // 二选一方案: 唯一昵称, 不允许重名 20 | NickName string `gorm:"index; type:varchar(128) CHARACTER SET utf8mb4; DEFAULT:''; COMMENT:'方案2:昵称+编号'; "` // 二选一方案: 昵称 + 昵称编号 21 | NickNo int64 `gorm:"index; type:varchar(128) CHARACTER SET utf8mb4; DEFAULT:''; COMMENT:'方案2:昵称+编号'; "` // 二选一方案: 昵称编号 22 | // auth: 23 | Register string 24 | MobileNo string // 手机号 25 | MobileCode string // 手机号国家码 26 | Email string // 邮箱 27 | Password string // 密码 28 | } 29 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/mq/hello.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | "github.com/better-go/pkg/mq/rabbitmq" 6 | ) 7 | 8 | // 用户登录认证: 9 | type HelloQueue struct { 10 | g *ConnGroup 11 | } 12 | 13 | func newHelloQueue(g *ConnGroup) *HelloQueue { 14 | return &HelloQueue{g: g} 15 | } 16 | 17 | func (m *HelloQueue) Publish(message string) error { 18 | err := m.g.cli.Publish( 19 | &rabbitmq.Exchange{ 20 | Name: "test-exchange", 21 | Type: "direct", 22 | Durable: false, 23 | AutoDelete: false, 24 | Internal: false, 25 | NoWait: false, 26 | Args: nil, 27 | }, 28 | &rabbitmq.Queue{ 29 | Name: "test-queue", 30 | Durable: true, 31 | AutoDelete: false, 32 | Exclusive: false, // 是否具有排他性 33 | NoWait: false, // 是否阻塞 34 | Args: nil, // 额外属性 35 | }, 36 | "test-routing-key", 37 | message, 38 | true, 39 | ) 40 | 41 | log.Infof("producer publish message: %v", err) 42 | return err 43 | } 44 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/mq/hello.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | "github.com/better-go/pkg/mq/rabbitmq" 6 | ) 7 | 8 | // 用户登录认证: 9 | type HelloQueue struct { 10 | g *ConnGroup 11 | } 12 | 13 | func newHelloQueue(g *ConnGroup) *HelloQueue { 14 | return &HelloQueue{g: g} 15 | } 16 | 17 | func (m *HelloQueue) Publish(message string) error { 18 | err := m.g.cli.Publish( 19 | &rabbitmq.Exchange{ 20 | Name: "test-exchange", 21 | Type: "direct", 22 | Durable: false, 23 | AutoDelete: false, 24 | Internal: false, 25 | NoWait: false, 26 | Args: nil, 27 | }, 28 | &rabbitmq.Queue{ 29 | Name: "test-queue", 30 | Durable: true, 31 | AutoDelete: false, 32 | Exclusive: false, // 是否具有排他性 33 | NoWait: false, // 是否阻塞 34 | Args: nil, // 额外属性 35 | }, 36 | "test-routing-key", 37 | message, 38 | true, 39 | ) 40 | 41 | log.Infof("producer publish message: %v", err) 42 | return err 43 | } 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[bug]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Describe the bug 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | ## To Reproduce 15 | 16 | > **NOTE**:Self-contained, minimal reproducing samples are extremely helpful and will expedite addressing your issue 17 | 18 | Steps to reproduce the behavior: 19 | 20 | 1. Go to '...' 21 | 2. Click on '....' 22 | 3. Scroll down to '....' 23 | 4. See error 24 | 25 | ## Expected behavior 26 | 27 | A clear and concise description of what you expected to happen. 28 | 29 | ## Screenshots 30 | 31 | If applicable, add screenshots to help explain your problem. 32 | 33 | ## Environment 34 | 35 | 36 | - Device: \[e.g. iPhone6] 37 | - OS: \[e.g. Ubuntu 18.04LTS] 38 | - Browser \[e.g. chrome, safari] 39 | - Version \[e.g. 22] 40 | 41 | ## Additional context 42 | 43 | Add any other context about the problem here. 44 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/server/admin.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | "github.com/tal-tech/go-zero/core/conf" 6 | "github.com/tal-tech/go-zero/rest" 7 | 8 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/router" 9 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/admin" 10 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 11 | ) 12 | 13 | // internal admin HTTP/API server: 14 | type AdminServer struct{} 15 | 16 | func (m *AdminServer) Run(configFile string) { 17 | // parse config: 18 | var cfg config.Config 19 | conf.MustLoad(configFile, &cfg) 20 | 21 | // admin api: 22 | svc := admin.NewService(cfg) 23 | defer svc.Close() 24 | 25 | // new engine: 26 | engine := rest.MustNewServer(cfg.Server.Admin.RestConf) 27 | defer engine.Stop() 28 | 29 | // register routes: 30 | router.RegisterAdminRoutes(engine, svc) 31 | 32 | log.Infof("starting admin api engine at %v\n", cfg.Server.Admin.RestConf) 33 | engine.Start() 34 | } 35 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/server/admin.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | "github.com/tal-tech/go-zero/core/conf" 6 | "github.com/tal-tech/go-zero/rest" 7 | 8 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/router" 9 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/service/admin" 10 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 11 | ) 12 | 13 | // internal admin HTTP/API server: 14 | type AdminServer struct{} 15 | 16 | func (m *AdminServer) Run(configFile string) { 17 | // parse config: 18 | var cfg config.Config 19 | conf.MustLoad(configFile, &cfg) 20 | 21 | // admin api: 22 | svc := admin.NewService(cfg) 23 | defer svc.Close() 24 | 25 | // new engine: 26 | engine := rest.MustNewServer(cfg.Server.Admin.RestConf) 27 | defer engine.Stop() 28 | 29 | // register routes: 30 | router.RegisterAdminRoutes(engine, svc) 31 | 32 | log.Infof("starting admin api engine at %v\n", cfg.Server.Admin.RestConf) 33 | engine.Start() 34 | } 35 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Go template 3 | # Binaries for programs and plugins 4 | *.exe 5 | *.exe~ 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Test binary, built with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | 16 | # Dependency directories (remove the comment below to include it) 17 | # vendor/ 18 | 19 | ################################################################################################################ 20 | # Add 2020: 21 | # 22 | # ref: 23 | # - https://github.com/caddyserver/caddy/blob/master/.gitignore 24 | # 25 | ################################################################################################################ 26 | 27 | # macOS 28 | .DS_Store 29 | 30 | # IDE: Goland 31 | .idea/ 32 | 33 | # IDE: VS Code 34 | .vscode/ 35 | 36 | # go mod 37 | vendor/ 38 | 39 | tmp/ 40 | *.log 41 | *.pb.go 42 | *.pb.micro.go 43 | 44 | # artifacts from pprof tooling 45 | *.prof 46 | 47 | # goreleaser artifacts 48 | dist/ 49 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/deploy/local/infra-kv-etcd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # MAC LOCAL IP: 5 | LOCAL_IP=`ifconfig | grep inet | grep -v inet6 | grep -v 127 | cut -d ' ' -f2` 6 | 7 | # LINUX LOCAL IP: 8 | #LOCAL_IP=`ip a | grep inet | grep -v inet6 | grep -v 127 | sed 's/^[ \t]*//g' | cut -d ' ' -f2` 9 | 10 | 11 | # set my host ip: 12 | #export LOCAL_IP=192.168.0.188 13 | export LOCAL_IP=${LOCAL_IP} 14 | 15 | 16 | export DATA_DIR="etcd-data" 17 | 18 | REGISTRY=quay.io/coreos/etcd 19 | # available from v3.2.5 20 | REGISTRY=gcr.io/etcd-development/etcd 21 | 22 | docker run -d \ 23 | -p 2379:2379 \ 24 | -p 2380:2380 \ 25 | -e ETCDCTL_API=3 \ 26 | --rm \ 27 | --volume=${DATA_DIR}:/etcd-data \ 28 | --name etcd ${REGISTRY}:latest \ 29 | /usr/local/bin/etcd \ 30 | --data-dir=/etcd-data --name LOCAL_IP \ 31 | --initial-advertise-peer-urls http://${LOCAL_IP}:2380 \ 32 | --listen-peer-urls http://0.0.0.0:2380 \ 33 | --advertise-client-urls http://${LOCAL_IP}:2379 \ 34 | --listen-client-urls http://0.0.0.0:2379 \ 35 | --initial-cluster node1=http://${LOCAL_IP}:2380 36 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/deploy/local/infra-kv-etcd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # MAC LOCAL IP: 5 | LOCAL_IP=`ifconfig | grep inet | grep -v inet6 | grep -v 127 | cut -d ' ' -f2` 6 | 7 | # LINUX LOCAL IP: 8 | #LOCAL_IP=`ip a | grep inet | grep -v inet6 | grep -v 127 | sed 's/^[ \t]*//g' | cut -d ' ' -f2` 9 | 10 | 11 | # set my host ip: 12 | #export LOCAL_IP=192.168.0.188 13 | export LOCAL_IP=${LOCAL_IP} 14 | 15 | 16 | export DATA_DIR="etcd-data" 17 | 18 | REGISTRY=quay.io/coreos/etcd 19 | # available from v3.2.5 20 | REGISTRY=gcr.io/etcd-development/etcd 21 | 22 | docker run -d \ 23 | -p 2379:2379 \ 24 | -p 2380:2380 \ 25 | -e ETCDCTL_API=3 \ 26 | --rm \ 27 | --volume=${DATA_DIR}:/etcd-data \ 28 | --name etcd ${REGISTRY}:latest \ 29 | /usr/local/bin/etcd \ 30 | --data-dir=/etcd-data --name LOCAL_IP \ 31 | --initial-advertise-peer-urls http://${LOCAL_IP}:2380 \ 32 | --listen-peer-urls http://0.0.0.0:2380 \ 33 | --advertise-client-urls http://${LOCAL_IP}:2379 \ 34 | --listen-client-urls http://0.0.0.0:2379 \ 35 | --initial-cluster node1=http://${LOCAL_IP}:2380 36 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/deploy/local/infra-kv-etcd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # MAC LOCAL IP: 5 | LOCAL_IP=`ifconfig | grep inet | grep -v inet6 | grep -v 127 | cut -d ' ' -f2` 6 | 7 | # LINUX LOCAL IP: 8 | #LOCAL_IP=`ip a | grep inet | grep -v inet6 | grep -v 127 | sed 's/^[ \t]*//g' | cut -d ' ' -f2` 9 | 10 | 11 | # set my host ip: 12 | #export LOCAL_IP=192.168.0.188 13 | export LOCAL_IP=${LOCAL_IP} 14 | 15 | 16 | export DATA_DIR="etcd-data" 17 | 18 | REGISTRY=quay.io/coreos/etcd 19 | # available from v3.2.5 20 | REGISTRY=gcr.io/etcd-development/etcd 21 | 22 | docker run -d \ 23 | -p 2379:2379 \ 24 | -p 2380:2380 \ 25 | -e ETCDCTL_API=3 \ 26 | --rm \ 27 | --volume=${DATA_DIR}:/etcd-data \ 28 | --name etcd ${REGISTRY}:latest \ 29 | /usr/local/bin/etcd \ 30 | --data-dir=/etcd-data --name LOCAL_IP \ 31 | --initial-advertise-peer-urls http://${LOCAL_IP}:2380 \ 32 | --listen-peer-urls http://0.0.0.0:2380 \ 33 | --advertise-client-urls http://${LOCAL_IP}:2379 \ 34 | --listen-client-urls http://0.0.0.0:2379 \ 35 | --initial-cluster node1=http://${LOCAL_IP}:2380 36 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Go template 3 | # Binaries for programs and plugins 4 | *.exe 5 | *.exe~ 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Test binary, built with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | 16 | # Dependency directories (remove the comment below to include it) 17 | vendor/ 18 | 19 | ################################################################################################################ 20 | 21 | # macOS 22 | .DS_Store 23 | 24 | # OS General 25 | Thumbs.db 26 | 27 | # IDE: Goland 28 | .idea/ 29 | 30 | # IDE: VS Code 31 | .vscode/ 32 | .history/ 33 | 34 | bin/ 35 | tmp/ 36 | *.log 37 | *.pb.go 38 | *.pb.micro.go 39 | # project 40 | *.cert 41 | *.key 42 | 43 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 44 | *.o 45 | *.a 46 | 47 | # Develop tools 48 | *.swp 49 | 50 | # artifacts from pprof tooling 51 | *.prof 52 | 53 | # goreleaser artifacts 54 | dist/ 55 | 56 | # env file: 57 | .env* 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/mq/mq.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "github.com/better-go/pkg/mq/rabbitmq" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 7 | ) 8 | 9 | type Dao struct { 10 | g *ConnGroup 11 | 12 | // biz: 13 | Hello *HelloQueue 14 | Block *BlockQueue 15 | } 16 | 17 | func New(cfg config.MQUnit) *Dao { 18 | // mq meta: 19 | g := newConnGroup(cfg) 20 | 21 | return &Dao{ 22 | g: g, 23 | 24 | // biz: 25 | Hello: newHelloQueue(g), 26 | Block: newBlockQueue(g), 27 | } 28 | } 29 | 30 | func (m *Dao) Close() { 31 | m.g.Close() 32 | return 33 | } 34 | 35 | ////////////////////////////////////////////////////////////////////////////////////////// 36 | 37 | // queue conn: 38 | type ConnGroup struct { 39 | cli *rabbitmq.Producer 40 | } 41 | 42 | func newConnGroup(cfg config.MQUnit) *ConnGroup { 43 | cli, _ := rabbitmq.NewProducer(&rabbitmq.ConnOption{ 44 | Uri: cfg.Demo.Url, 45 | }) 46 | 47 | return &ConnGroup{ 48 | cli: cli, 49 | } 50 | } 51 | 52 | func (m *ConnGroup) Close() { 53 | m.cli.Close() 54 | } 55 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/mq/mq.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "github.com/better-go/pkg/mq/rabbitmq" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 7 | ) 8 | 9 | type Dao struct { 10 | g *ConnGroup 11 | 12 | // biz: 13 | Hello *HelloQueue 14 | Block *BlockQueue 15 | } 16 | 17 | func New(cfg config.MQUnit) *Dao { 18 | // mq meta: 19 | g := newConnGroup(cfg) 20 | 21 | return &Dao{ 22 | g: g, 23 | 24 | // biz: 25 | Hello: newHelloQueue(g), 26 | Block: newBlockQueue(g), 27 | } 28 | } 29 | 30 | func (m *Dao) Close() { 31 | m.g.Close() 32 | return 33 | } 34 | 35 | ////////////////////////////////////////////////////////////////////////////////////////// 36 | 37 | // queue conn: 38 | type ConnGroup struct { 39 | cli *rabbitmq.Producer 40 | } 41 | 42 | func newConnGroup(cfg config.MQUnit) *ConnGroup { 43 | cli, _ := rabbitmq.NewProducer(&rabbitmq.ConnOption{ 44 | Uri: cfg.Demo.Url, 45 | }) 46 | 47 | return &ConnGroup{ 48 | cli: cli, 49 | } 50 | } 51 | 52 | func (m *ConnGroup) Close() { 53 | m.cli.Close() 54 | } 55 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/server/outer.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/better-go/pkg/log" 7 | "github.com/tal-tech/go-zero/core/conf" 8 | "github.com/tal-tech/go-zero/rest" 9 | 10 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/router" 11 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/outer" 12 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 13 | ) 14 | 15 | // interface HTTP/API server: 16 | type OuterServer struct{} 17 | 18 | func (m *OuterServer) Run(configFile string) { 19 | ctx := context.Background() 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | 25 | // api engine: 26 | svc := outer.NewService(cfg, ctx) 27 | defer svc.Close() 28 | 29 | // new engine: 30 | engine := rest.MustNewServer(cfg.Server.Outer.RestConf) 31 | defer engine.Stop() 32 | 33 | // register routes: 34 | router.RegisterApiRoutes(engine, svc) 35 | 36 | log.Infof("starting api engine at %v\n", cfg.Server.Outer.RestConf) 37 | engine.Start() 38 | } 39 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Go template 3 | # Binaries for programs and plugins 4 | *.exe 5 | *.exe~ 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Test binary, built with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | 16 | # Dependency directories (remove the comment below to include it) 17 | vendor/ 18 | 19 | ################################################################################################################ 20 | 21 | # macOS 22 | .DS_Store 23 | 24 | # OS General 25 | Thumbs.db 26 | 27 | # IDE: Goland 28 | .idea/ 29 | 30 | # IDE: VS Code 31 | .vscode/ 32 | .history/ 33 | 34 | bin/ 35 | tmp/ 36 | *.log 37 | *.pb.go 38 | *.pb.micro.go 39 | # project 40 | *.cert 41 | *.key 42 | 43 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 44 | *.o 45 | *.a 46 | 47 | # Develop tools 48 | *.swp 49 | 50 | # artifacts from pprof tooling 51 | *.prof 52 | 53 | # goreleaser artifacts 54 | dist/ 55 | 56 | # env file: 57 | .env* 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/server/inner.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | "github.com/tal-tech/go-zero/core/conf" 6 | "github.com/tal-tech/go-zero/zrpc" 7 | "google.golang.org/grpc" 8 | 9 | "{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/inner" 10 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/config" 11 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/rpc" 12 | ) 13 | 14 | // internal gRPC server: 15 | type InnerServer struct{} 16 | 17 | func (m *InnerServer) Run(configFile string) { 18 | // parse config: 19 | var cfg config.Config 20 | conf.MustLoad(configFile, &cfg) 21 | 22 | // rpc service: 23 | svc := inner.NewService(cfg) 24 | defer svc.Close() 25 | 26 | // new rpc engine: 27 | engine := zrpc.MustNewServer(cfg.Server.Inner.RpcServerConf, func(server *grpc.Server) { 28 | // register rpc server 29 | rpc.RegisterQueueServiceServer(server, svc) 30 | }) 31 | defer engine.Stop() 32 | 33 | log.Infof("starting rpc engine at %v\n", cfg.Server.Inner.RpcServerConf) 34 | engine.Start() 35 | } 36 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Go template 3 | # Binaries for programs and plugins 4 | *.exe 5 | *.exe~ 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Test binary, built with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | 16 | # Dependency directories (remove the comment below to include it) 17 | # vendor/ 18 | 19 | ################################################################################################################ 20 | # Add 2020: 21 | # 22 | # ref: 23 | # - https://github.com/caddyserver/caddy/blob/master/.gitignore 24 | # 25 | ################################################################################################################ 26 | 27 | # macOS 28 | .DS_Store 29 | 30 | # IDE: Goland 31 | .idea/ 32 | 33 | # IDE: VS Code 34 | .vscode/ 35 | 36 | # go mod 37 | vendor/ 38 | 39 | tmp/ 40 | *.log 41 | *.pb.go 42 | *.pb.micro.go 43 | 44 | # artifacts from pprof tooling 45 | *.prof 46 | 47 | # goreleaser artifacts 48 | dist/ 49 | 50 | # env file: 51 | .env 52 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/server/outer.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/better-go/pkg/log" 7 | "github.com/tal-tech/go-zero/core/conf" 8 | "github.com/tal-tech/go-zero/rest" 9 | 10 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/router" 11 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/service/outer" 12 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 13 | ) 14 | 15 | // interface HTTP/API server: 16 | type OuterServer struct{} 17 | 18 | func (m *OuterServer) Run(configFile string) { 19 | ctx := context.Background() 20 | 21 | // parse config: 22 | var cfg config.Config 23 | conf.MustLoad(configFile, &cfg) 24 | 25 | // api engine: 26 | svc := outer.NewService(cfg, ctx) 27 | defer svc.Close() 28 | 29 | // new engine: 30 | engine := rest.MustNewServer(cfg.Server.Outer.RestConf) 31 | defer engine.Stop() 32 | 33 | // register routes: 34 | router.RegisterApiRoutes(engine, svc) 35 | 36 | log.Infof("starting api engine at %v\n", cfg.Server.Outer.RestConf) 37 | engine.Start() 38 | } 39 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/server/inner.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/better-go/pkg/log" 5 | "github.com/tal-tech/go-zero/core/conf" 6 | "github.com/tal-tech/go-zero/zrpc" 7 | "google.golang.org/grpc" 8 | 9 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/service/inner" 10 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 11 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/rpc" 12 | ) 13 | 14 | // internal gRPC server: 15 | type InnerServer struct{} 16 | 17 | func (m *InnerServer) Run(configFile string) { 18 | // parse config: 19 | var cfg config.Config 20 | conf.MustLoad(configFile, &cfg) 21 | 22 | // rpc service: 23 | svc := inner.NewService(cfg) 24 | defer svc.Close() 25 | 26 | // new rpc engine: 27 | engine := zrpc.MustNewServer(cfg.Server.Inner.RpcServerConf, func(server *grpc.Server) { 28 | // register rpc server 29 | rpc.RegisterQueueServiceServer(server, svc) 30 | }) 31 | defer engine.Stop() 32 | 33 | log.Infof("starting rpc engine at %v\n", cfg.Server.Inner.RpcServerConf) 34 | engine.Start() 35 | } 36 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Henry Huang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Henry Huang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/go.mod: -------------------------------------------------------------------------------- 1 | module creator-mate 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/Shopify/sarama v1.26.1 // indirect 7 | github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect 8 | github.com/go-critic/go-critic v0.4.3 9 | github.com/go-redis/redis/v7 v7.2.0 10 | github.com/go-sql-driver/mysql v1.5.0 11 | github.com/gocarina/gocsv v0.0.0-20200330101823-46266ca37bd3 12 | github.com/golang/protobuf v1.3.5 13 | github.com/gomodule/redigo v2.0.0+incompatible 14 | github.com/google/uuid v1.1.1 15 | github.com/jinzhu/gorm v1.9.12 16 | github.com/jinzhu/now v1.1.1 17 | github.com/klauspost/compress v1.10.5 // indirect 18 | github.com/micro/go-micro/v2 v2.3.0 19 | github.com/micro/micro/v2 v2.3.1 20 | github.com/microcosm-cc/bluemonday v1.0.2 21 | github.com/pierrec/lz4 v2.5.2+incompatible // indirect 22 | github.com/pkg/errors v0.9.1 23 | github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect 24 | github.com/rs/xid v1.2.1 25 | golang.org/x/crypto v0.0.0-20200422194213-44a606286825 // indirect 26 | golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f 27 | golang.org/x/net v0.0.0-20200421231249-e086a090c8fd // indirect 28 | ) 29 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/service/service.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/domain/{{cookiecutter.app_name}}" 7 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/api" 8 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/config" 9 | 10 | "github.com/better-go/pkg/log" 11 | ) 12 | 13 | // Service 对应 gRPC API 映射 14 | type Service struct { 15 | Demo *{{cookiecutter.app_name}}.Scope // 推送服务 16 | } 17 | 18 | func New(cfg *config.Config) *Service { 19 | return &Service{ 20 | Demo: {{cookiecutter.app_name}}.NewScope(cfg), 21 | } 22 | } 23 | 24 | ////////////////////////////////////////////////////////////////////////////////////////////////////////// 25 | 26 | func (m *Service) Hello(ctx context.Context, req *api.HelloReq) (resp *api.HelloResp, err error) { 27 | resp = new(api.HelloResp) 28 | resp.Reply = req.Message + ", reply to you." 29 | 30 | // call: 31 | err = m.Demo.Demo.Hello(ctx, req.Message) 32 | log.Infof("service.Demo.Hello done, req=%+v, resp=%+v", req, resp) 33 | 34 | return resp, err 35 | } 36 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 {{cookiecutter.author_name}} ({{cookiecutter.author_email}}) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/db/user.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/model" 7 | ) 8 | 9 | // 用户登录认证: 10 | type UserStorage struct { 11 | g *ConnGroup 12 | } 13 | 14 | func newUserStorage(g *ConnGroup) *UserStorage { 15 | return &UserStorage{g: g} 16 | } 17 | 18 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 19 | 20 | func (m *UserStorage) CreateUserMeta(ctx context.Context, req *model.UserMeta) (int64, error) { 21 | ret := m.g.DB.DB().Create(req) 22 | return ret.RowsAffected, ret.Error 23 | } 24 | 25 | func (m *UserStorage) UserMeta(ctx context.Context, userID uint64) (*model.UserMeta, error) { 26 | resp := new(model.UserMeta) 27 | 28 | err := m.g.DB.DB().Where(&model.UserMeta{UserID: userID}).Find(&resp).Error 29 | return resp, err 30 | } 31 | 32 | func (m *UserStorage) UserMetaWithCache(ctx context.Context, userID uint64) (*model.UserMeta, error) { 33 | resp := new(model.UserMeta) 34 | 35 | //m.g.DBX.QueryRow() 36 | 37 | err := m.g.DB.DB().Where(&model.UserMeta{UserID: userID}).Find(&resp).Error 38 | return resp, err 39 | } 40 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/pkg/x/google/api/annotations.proto: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/http.proto"; 20 | import "google/protobuf/descriptor.proto"; 21 | 22 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "AnnotationsProto"; 25 | option java_package = "com.google.api"; 26 | option objc_class_prefix = "GAPI"; 27 | 28 | extend google.protobuf.MethodOptions { 29 | // See `HttpRule`. 30 | HttpRule http = 72295728; 31 | } 32 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/db/user.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "context" 5 | 6 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/model" 7 | ) 8 | 9 | // 用户登录认证: 10 | type UserStorage struct { 11 | g *ConnGroup 12 | } 13 | 14 | func newUserStorage(g *ConnGroup) *UserStorage { 15 | return &UserStorage{g: g} 16 | } 17 | 18 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 19 | 20 | func (m *UserStorage) CreateUserMeta(ctx context.Context, req *model.UserMeta) (int64, error) { 21 | ret := m.g.DB.DB().Create(req) 22 | return ret.RowsAffected, ret.Error 23 | } 24 | 25 | func (m *UserStorage) UserMeta(ctx context.Context, userID uint64) (*model.UserMeta, error) { 26 | resp := new(model.UserMeta) 27 | 28 | err := m.g.DB.DB().Where(&model.UserMeta{UserID: userID}).Find(&resp).Error 29 | return resp, err 30 | } 31 | 32 | func (m *UserStorage) UserMetaWithCache(ctx context.Context, userID uint64) (*model.UserMeta, error) { 33 | resp := new(model.UserMeta) 34 | 35 | //m.g.DBX.QueryRow() 36 | 37 | err := m.g.DB.DB().Where(&model.UserMeta{UserID: userID}).Find(&resp).Error 38 | return resp, err 39 | } 40 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/cache/hello.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | ) 7 | 8 | const ( 9 | // redis key fmt: 10 | _fmtKeyHello = "auth:%v" 11 | ) 12 | 13 | type HelloCache struct { 14 | g *ConnGroup 15 | } 16 | 17 | func newHelloCache(g *ConnGroup) *HelloCache { 18 | return &HelloCache{g: g} 19 | } 20 | 21 | ////////////////////////////////////////////////////////////////////////////////////////// 22 | 23 | // redis key: 24 | func keyHello(userID int64) string { 25 | return fmt.Sprintf(_fmtKeyHello, userID) 26 | } 27 | 28 | ////////////////////////////////////////////////////////////////////////////////////////// 29 | 30 | // set: 31 | func (m *HelloCache) Set(ctx context.Context, userID int64, token string) error { 32 | //key := keyHello(userID) 33 | //expire := m.g.Expire.Minutes(1) 34 | 35 | // todo: need set cache 36 | return nil 37 | //return m.g.RDS1.V1().Set(ctx, key, token, expire).Err() 38 | } 39 | 40 | // get: 41 | func (m *HelloCache) Get(ctx context.Context, userID int64) (int64, error) { 42 | //key := keyHello(userID) 43 | 44 | // todo: need query cache 45 | return 0, nil 46 | //ret, err := m.g.RDS1.V1().Get(ctx, key).Int64() 47 | //return ret, err 48 | } 49 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/service/inner/handler.go: -------------------------------------------------------------------------------- 1 | package inner 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | "time" 8 | 9 | "github.com/better-go/pkg/log" 10 | 11 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/proto/rpc" 12 | ) 13 | 14 | func (m *Service) Grace(ctx context.Context, req *rpc.Request) (*rpc.Response, error) { 15 | log.Infof("inner rpc call: %+v", req) 16 | 17 | time.Sleep(time.Millisecond * 10) 18 | 19 | hostname, err := os.Hostname() 20 | if err != nil { 21 | return nil, err 22 | } 23 | 24 | return &rpc.Response{ 25 | Host: hostname, 26 | }, nil 27 | } 28 | 29 | func (m *Service) AdminCall(ctx context.Context, req *rpc.AdminReq) (*rpc.AdminResp, error) { 30 | log.Infof("inner rpc AdminCall req: %+v", req) 31 | 32 | return &rpc.AdminResp{ 33 | Message: fmt.Sprintf("hello from rpc admin api, now = %+v", time.Now()), 34 | Status: "ok", 35 | }, nil 36 | } 37 | 38 | func (m *Service) RestCall(ctx context.Context, req *rpc.RestReq) (*rpc.RestResp, error) { 39 | log.Infof("inner rpc RestCall req: %+v", req) 40 | 41 | return &rpc.RestResp{ 42 | Message: fmt.Sprintf("hello from rpc rest api, now = %+v", time.Now()), 43 | Status: "ok", 44 | }, nil 45 | } 46 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/service/inner/handler.go: -------------------------------------------------------------------------------- 1 | package inner 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | "time" 8 | 9 | "github.com/better-go/pkg/log" 10 | 11 | "{{cookiecutter.go_module_name}}/app/basic/demo/proto/rpc" 12 | ) 13 | 14 | func (m *Service) Grace(ctx context.Context, req *rpc.Request) (*rpc.Response, error) { 15 | log.Infof("inner rpc call: %+v", req) 16 | 17 | time.Sleep(time.Millisecond * 10) 18 | 19 | hostname, err := os.Hostname() 20 | if err != nil { 21 | return nil, err 22 | } 23 | 24 | return &rpc.Response{ 25 | Host: hostname, 26 | }, nil 27 | } 28 | 29 | func (m *Service) AdminCall(ctx context.Context, req *rpc.AdminReq) (*rpc.AdminResp, error) { 30 | log.Infof("inner rpc AdminCall req: %+v", req) 31 | 32 | return &rpc.AdminResp{ 33 | Message: fmt.Sprintf("hello from rpc admin api, now = %+v", time.Now()), 34 | Status: "ok", 35 | }, nil 36 | } 37 | 38 | func (m *Service) RestCall(ctx context.Context, req *rpc.RestReq) (*rpc.RestResp, error) { 39 | log.Infof("inner rpc RestCall req: %+v", req) 40 | 41 | return &rpc.RestResp{ 42 | Message: fmt.Sprintf("hello from rpc rest api, now = %+v", time.Now()), 43 | Status: "ok", 44 | }, nil 45 | } 46 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/cache/hello.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | ) 7 | 8 | const ( 9 | // redis key fmt: 10 | _fmtKeyHello = "auth:%v" 11 | ) 12 | 13 | type HelloCache struct { 14 | g *ConnGroup 15 | } 16 | 17 | func newHelloCache(g *ConnGroup) *HelloCache { 18 | return &HelloCache{g: g} 19 | } 20 | 21 | ////////////////////////////////////////////////////////////////////////////////////////// 22 | 23 | // redis key: 24 | func keyHello(userID int64) string { 25 | return fmt.Sprintf(_fmtKeyHello, userID) 26 | } 27 | 28 | ////////////////////////////////////////////////////////////////////////////////////////// 29 | 30 | // set: 31 | func (m *HelloCache) Set(ctx context.Context, userID int64, token string) error { 32 | //key := keyHello(userID) 33 | //expire := m.g.Expire.Minutes(1) 34 | 35 | // todo: need set cache 36 | return nil 37 | //return m.g.RDS1.V1().Set(ctx, key, token, expire).Err() 38 | } 39 | 40 | // get: 41 | func (m *HelloCache) Get(ctx context.Context, userID int64) (int64, error) { 42 | //key := keyHello(userID) 43 | 44 | // todo: need query cache 45 | return 0, nil 46 | //ret, err := m.g.RDS1.V1().Get(ctx, key).Int64() 47 | //return ret, err 48 | } 49 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/.codecov.yml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # 3 | # ref: 4 | # - https://codecov.io/ 5 | # - https://github.com/codecov 6 | # - https://docs.coveralls.io/go 7 | # - https://github.com/pingcap/tidb/blob/master/.codecov.yml 8 | # 9 | ################################################################################################################ 10 | 11 | codecov: 12 | notify: 13 | require_ci_to_pass: yes 14 | 15 | coverage: 16 | precision: 4 17 | round: down 18 | range: "65...90" 19 | 20 | status: 21 | project: 22 | default: 23 | threshold: 0.2 #Allow the coverage to drop by threshold%, and posting a success status. 24 | patch: 25 | default: 26 | target: 0% # trial operation 27 | changes: no 28 | 29 | parsers: 30 | gcov: 31 | branch_detection: 32 | conditional: yes 33 | loop: yes 34 | method: no 35 | macro: no 36 | 37 | comment: 38 | layout: "header, diff" 39 | behavior: default 40 | require_changes: no 41 | 42 | ignore: 43 | - "LICENSES" 44 | - "*_test.go" 45 | - ".git" 46 | - "*.yml" 47 | - "*.md" 48 | - "doc/.*" 49 | - "vendor/.*" 50 | 51 | 52 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/.codecov.yml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # 3 | # ref: 4 | # - https://codecov.io/ 5 | # - https://github.com/codecov 6 | # - https://docs.coveralls.io/go 7 | # - https://github.com/pingcap/tidb/blob/master/.codecov.yml 8 | # 9 | ################################################################################################################ 10 | 11 | codecov: 12 | notify: 13 | require_ci_to_pass: yes 14 | 15 | coverage: 16 | precision: 4 17 | round: down 18 | range: "65...90" 19 | 20 | status: 21 | project: 22 | default: 23 | threshold: 0.2 #Allow the coverage to drop by threshold%, and posting a success status. 24 | patch: 25 | default: 26 | target: 0% # trial operation 27 | changes: no 28 | 29 | parsers: 30 | gcov: 31 | branch_detection: 32 | conditional: yes 33 | loop: yes 34 | method: no 35 | macro: no 36 | 37 | comment: 38 | layout: "header, diff" 39 | behavior: default 40 | require_changes: no 41 | 42 | ignore: 43 | - "LICENSES" 44 | - "*_test.go" 45 | - ".git" 46 | - "*.yml" 47 | - "*.md" 48 | - "doc/.*" 49 | - "vendor/.*" 50 | 51 | 52 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/.codecov.yml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # 3 | # ref: 4 | # - https://codecov.io/ 5 | # - https://github.com/codecov 6 | # - https://docs.coveralls.io/go 7 | # - https://github.com/pingcap/tidb/blob/master/.codecov.yml 8 | # 9 | ################################################################################################################ 10 | 11 | codecov: 12 | notify: 13 | require_ci_to_pass: yes 14 | 15 | coverage: 16 | precision: 4 17 | round: down 18 | range: "65...90" 19 | 20 | status: 21 | project: 22 | default: 23 | threshold: 0.2 #Allow the coverage to drop by threshold%, and posting a success status. 24 | patch: 25 | default: 26 | target: 0% # trial operation 27 | changes: no 28 | 29 | parsers: 30 | gcov: 31 | branch_detection: 32 | conditional: yes 33 | loop: yes 34 | method: no 35 | macro: no 36 | 37 | comment: 38 | layout: "header, diff" 39 | behavior: default 40 | require_changes: no 41 | 42 | ignore: 43 | - "LICENSES" 44 | - "*_test.go" 45 | - ".git" 46 | - "*.yml" 47 | - "*.md" 48 | - "doc/.*" 49 | - "vendor/.*" 50 | 51 | 52 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/.codecov.yml: -------------------------------------------------------------------------------- 1 | ################################################################################################################ 2 | # 3 | # ref: 4 | # - https://codecov.io/ 5 | # - https://github.com/codecov 6 | # - https://docs.coveralls.io/go 7 | # - https://github.com/pingcap/tidb/blob/master/.codecov.yml 8 | # 9 | ################################################################################################################ 10 | 11 | codecov: 12 | notify: 13 | require_ci_to_pass: yes 14 | 15 | coverage: 16 | precision: 4 17 | round: down 18 | range: "65...90" 19 | 20 | status: 21 | project: 22 | default: 23 | threshold: 0.2 #Allow the coverage to drop by threshold%, and posting a success status. 24 | patch: 25 | default: 26 | target: 0% # trial operation 27 | changes: no 28 | 29 | parsers: 30 | gcov: 31 | branch_detection: 32 | conditional: yes 33 | loop: yes 34 | method: no 35 | macro: no 36 | 37 | comment: 38 | layout: "header, diff" 39 | behavior: default 40 | require_changes: no 41 | 42 | ignore: 43 | - "LICENSES" 44 | - "*_test.go" 45 | - ".git" 46 | - "*.yml" 47 | - "*.md" 48 | - "doc/.*" 49 | - "vendor/.*" 50 | 51 | 52 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/.pre-commit-config.yml: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # See https://pre-commit.com for more information 3 | # See https://pre-commit.com/hooks.html for more hooks 4 | # ref: 5 | # - https://pre-commit.com/#pre-commit-configyaml---hooks 6 | # usage repo: 7 | # - hook list: https://pre-commit.com/hooks.html 8 | # - golang: 9 | # - https://github.com/TekWizely/pre-commit-golang 10 | # - https://github.com/dnephin/pre-commit-golang 11 | # - https://github.com/lietu/go-pre-commit 12 | # 13 | # ============================================================================== 14 | 15 | 16 | repos: 17 | # 18 | # 插件库列表: 19 | # 20 | - repo: https://github.com/pre-commit/pre-commit-hooks 21 | rev: v2.0.0 22 | hooks: 23 | - id: check-merge-conflict 24 | - id: trailing-whitespace 25 | - id: check-yaml 26 | 27 | # 28 | # for golang: 29 | # 30 | - repo: git://github.com/dnephin/pre-commit-golang 31 | rev: master 32 | hooks: 33 | - id: go-fmt 34 | - id: go-imports 35 | - id: validate-toml 36 | - id: no-go-testing 37 | # - id: golangci-lint 38 | # - id: go-unit-tests # 单元测试, 有效 39 | # - id: go-build 40 | -------------------------------------------------------------------------------- /mono-repo/gin/{{cookiecutter.repo_name}}/.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # See https://pre-commit.com for more information 3 | # See https://pre-commit.com/hooks.html for more hooks 4 | # ref: 5 | # - https://pre-commit.com/#pre-commit-configyaml---hooks 6 | # usage repo: 7 | # - hook list: https://pre-commit.com/hooks.html 8 | # - golang: 9 | # - https://github.com/TekWizely/pre-commit-golang 10 | # - https://github.com/dnephin/pre-commit-golang 11 | # - https://github.com/lietu/go-pre-commit 12 | # 13 | # ============================================================================== 14 | 15 | 16 | repos: 17 | # 18 | # 插件库列表: 19 | # 20 | - repo: https://github.com/pre-commit/pre-commit-hooks 21 | rev: v2.0.0 22 | hooks: 23 | - id: check-merge-conflict 24 | - id: trailing-whitespace 25 | - id: check-yaml 26 | 27 | # 28 | # for golang: 29 | # 30 | - repo: git://github.com/dnephin/pre-commit-golang 31 | rev: master 32 | hooks: 33 | - id: go-fmt 34 | - id: go-imports 35 | - id: validate-toml 36 | - id: no-go-testing 37 | - id: golangci-lint 38 | # - id: go-unit-tests # 单元测试, 有效 39 | # - id: go-build 40 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/.pre-commit-config.yml: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # See https://pre-commit.com for more information 3 | # See https://pre-commit.com/hooks.html for more hooks 4 | # ref: 5 | # - https://pre-commit.com/#pre-commit-configyaml---hooks 6 | # usage repo: 7 | # - hook list: https://pre-commit.com/hooks.html 8 | # - golang: 9 | # - https://github.com/TekWizely/pre-commit-golang 10 | # - https://github.com/dnephin/pre-commit-golang 11 | # - https://github.com/lietu/go-pre-commit 12 | # 13 | # ============================================================================== 14 | 15 | 16 | repos: 17 | # 18 | # 插件库列表: 19 | # 20 | - repo: https://github.com/pre-commit/pre-commit-hooks 21 | rev: v2.0.0 22 | hooks: 23 | - id: check-merge-conflict 24 | - id: trailing-whitespace 25 | - id: check-yaml 26 | 27 | # 28 | # for golang: 29 | # 30 | - repo: git://github.com/dnephin/pre-commit-golang 31 | rev: master 32 | hooks: 33 | - id: go-fmt 34 | - id: go-imports 35 | - id: validate-toml 36 | - id: no-go-testing 37 | # - id: golangci-lint 38 | # - id: go-unit-tests # 单元测试, 有效 39 | # - id: go-build 40 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # See https://pre-commit.com for more information 3 | # See https://pre-commit.com/hooks.html for more hooks 4 | # ref: 5 | # - https://pre-commit.com/#pre-commit-configyaml---hooks 6 | # usage repo: 7 | # - hook list: https://pre-commit.com/hooks.html 8 | # - golang: 9 | # - https://github.com/TekWizely/pre-commit-golang 10 | # - https://github.com/dnephin/pre-commit-golang 11 | # - https://github.com/lietu/go-pre-commit 12 | # 13 | # ============================================================================== 14 | 15 | 16 | repos: 17 | # 18 | # 插件库列表: 19 | # 20 | - repo: https://github.com/pre-commit/pre-commit-hooks 21 | rev: v2.0.0 22 | hooks: 23 | - id: check-merge-conflict 24 | - id: trailing-whitespace 25 | - id: check-yaml 26 | 27 | # 28 | # for golang: 29 | # 30 | - repo: git://github.com/dnephin/pre-commit-golang 31 | rev: master 32 | hooks: 33 | - id: go-fmt 34 | - id: go-imports 35 | - id: validate-toml 36 | - id: no-go-testing 37 | # - id: golangci-lint 38 | # - id: go-unit-tests # 单元测试, 有效 39 | # - id: go-build 40 | -------------------------------------------------------------------------------- /single-app/gin/{{cookiecutter.app_name}}/internal/router/router.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "{{cookiecutter.app_relative_path}}/{{cookiecutter.app_name}}/internal/service" 5 | 6 | "github.com/gin-gonic/gin" 7 | ginSwagger "github.com/swaggo/gin-swagger" 8 | "github.com/swaggo/gin-swagger/swaggerFiles" 9 | ) 10 | 11 | var ( 12 | gs *service.Service // gs = global service object, for global use 13 | ) 14 | 15 | // http api register: 16 | func RegisterRouter(r *gin.Engine, srv *service.Service) { 17 | // 18 | // global use 19 | // 20 | gs = srv 21 | 22 | // swagger docs: for debug 23 | r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) 24 | 25 | // api: 26 | v1 := r.Group("api/v1") 27 | { 28 | v1.POST("/post", post) 29 | v1.GET("/ping", ping) 30 | 31 | // push: 推送服务 32 | push := v1.Group("/demo") 33 | { 34 | push.POST("/hello", hello) // demo.Hello() 35 | } 36 | } 37 | 38 | // debug test: 39 | debug := r.Group("internal/debug") 40 | { 41 | // test: 42 | debug.GET("/test", func(ctx *gin.Context) { 43 | ctx.JSON(200, gin.H{ 44 | "message": "debug test", 45 | }) 46 | }) 47 | 48 | // etc: 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/deploy/local/infra-kv-etcd.yml: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # etcd service: 3 | # ref: 4 | # - https://github.com/evildecay/etcdkeeper 5 | # - 本地浏览器访问: 6 | # - http://0.0.0.0:12001 7 | # - 手动设置 etcd 地址: 8 | # - 需要指定: 本机本地 IP (192.168.2.10:2379) 9 | # - 非 127.0.0.1 和 0.0.0.0 10 | # - 亲测有效 11 | ########################################################################################## 12 | 13 | version: '3.5' 14 | 15 | # SET ENV: in .env file 16 | 17 | 18 | services: 19 | # etcd: 20 | discov: 21 | image: gcr.io/etcd-development/etcd:latest 22 | container_name: discov 23 | environment: 24 | ETCDCTL_API: "3" # api version 25 | # ALLOW_NONE_AUTHENTICATION: yes 26 | ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380 27 | ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379 28 | ETCD_INITIAL_ADVERTISE_PEER_URLS: "${ENV_LOCAL_IP}:2380" # my host ip 29 | ETCD_ADVERTISE_CLIENT_URLS: "${ENV_LOCAL_IP}:2379" # my host ip 30 | ETCD_INITIAL_CLUSTER: "node1=${ENV_LOCAL_IP}:2380" 31 | # ETCD_NAME: "etcd1" 32 | ports: 33 | - 2379:2379 34 | - 2380:2380 35 | - 4001:4001 36 | #network_mode: "host" # fix ETCD_LISTEN_CLIENT_URLS 37 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/deploy/local/infra-kv-etcd.yml: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # etcd service: 3 | # ref: 4 | # - https://github.com/evildecay/etcdkeeper 5 | # - 本地浏览器访问: 6 | # - http://0.0.0.0:12001 7 | # - 手动设置 etcd 地址: 8 | # - 需要指定: 本机本地 IP (192.168.2.10:2379) 9 | # - 非 127.0.0.1 和 0.0.0.0 10 | # - 亲测有效 11 | ########################################################################################## 12 | 13 | version: '3.5' 14 | 15 | # SET ENV: in .env file 16 | 17 | 18 | services: 19 | # etcd: 20 | discov: 21 | image: gcr.io/etcd-development/etcd:latest 22 | container_name: discov 23 | environment: 24 | ETCDCTL_API: "3" # api version 25 | # ALLOW_NONE_AUTHENTICATION: yes 26 | ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380 27 | ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379 28 | ETCD_INITIAL_ADVERTISE_PEER_URLS: "${ENV_LOCAL_IP}:2380" # my host ip 29 | ETCD_ADVERTISE_CLIENT_URLS: "${ENV_LOCAL_IP}:2379" # my host ip 30 | ETCD_INITIAL_CLUSTER: "node1=${ENV_LOCAL_IP}:2380" 31 | # ETCD_NAME: "etcd1" 32 | ports: 33 | - 2379:2379 34 | - 2380:2380 35 | - 4001:4001 36 | #network_mode: "host" # fix ETCD_LISTEN_CLIENT_URLS 37 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/deploy/local/infra-kv-etcd.yml: -------------------------------------------------------------------------------- 1 | ########################################################################################## 2 | # etcd service: 3 | # ref: 4 | # - https://github.com/evildecay/etcdkeeper 5 | # - 本地浏览器访问: 6 | # - http://0.0.0.0:12001 7 | # - 手动设置 etcd 地址: 8 | # - 需要指定: 本机本地 IP (192.168.2.10:2379) 9 | # - 非 127.0.0.1 和 0.0.0.0 10 | # - 亲测有效 11 | ########################################################################################## 12 | 13 | version: '3.5' 14 | 15 | # SET ENV: in .env file 16 | 17 | 18 | services: 19 | # etcd: 20 | discov: 21 | image: gcr.io/etcd-development/etcd:latest 22 | container_name: discov 23 | environment: 24 | ETCDCTL_API: "3" # api version 25 | # ALLOW_NONE_AUTHENTICATION: yes 26 | ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380 27 | ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379 28 | ETCD_INITIAL_ADVERTISE_PEER_URLS: "${ENV_LOCAL_IP}:2380" # my host ip 29 | ETCD_ADVERTISE_CLIENT_URLS: "${ENV_LOCAL_IP}:2379" # my host ip 30 | ETCD_INITIAL_CLUSTER: "node1=${ENV_LOCAL_IP}:2380" 31 | # ETCD_NAME: "etcd1" 32 | ports: 33 | - 2379:2379 34 | - 2380:2380 35 | - 4001:4001 36 | #network_mode: "host" # fix ETCD_LISTEN_CLIENT_URLS 37 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/internal/dao/mq/block.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "github.com/better-go/pkg/mq/rabbitmq" 5 | ) 6 | 7 | // block: 8 | type BlockQueue struct { 9 | g *ConnGroup 10 | } 11 | 12 | func newBlockQueue(g *ConnGroup) *BlockQueue { 13 | return &BlockQueue{g: g} 14 | } 15 | 16 | // CreateMarketEvents 17 | func (m *BlockQueue) PublishCreateMarketEvents(message string) error { 18 | queueName := "CreateMarketEventsQueue" 19 | return m.publish(message, queueName) 20 | } 21 | 22 | // FinalizeMarketEvents 23 | func (m *BlockQueue) PublishFinalizeMarketEvents(message string) error { 24 | queueName := "FinalizeMarketEventsQueue" 25 | return m.publish(message, queueName) 26 | } 27 | 28 | // pub: 29 | func (m *BlockQueue) publish(message string, queueName string) error { 30 | exchangeName := "BlockExchange" 31 | return m.g.cli.Publish( 32 | &rabbitmq.Exchange{ 33 | Name: exchangeName, 34 | Type: "direct", 35 | Durable: false, 36 | AutoDelete: false, 37 | Internal: false, 38 | NoWait: false, 39 | Args: nil, 40 | }, 41 | &rabbitmq.Queue{ 42 | Name: queueName, 43 | Durable: true, 44 | AutoDelete: false, 45 | Exclusive: false, // 是否具有排他性 46 | NoWait: false, // 是否阻塞 47 | Args: nil, // 额外属性 48 | }, 49 | queueName, 50 | message, 51 | true, 52 | ) 53 | } 54 | -------------------------------------------------------------------------------- /single-app/go-zero/{{cookiecutter.app_name}}/proto/model/graphql/graph_test.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestQueryCreateMarketEvents_ToJsonString(t *testing.T) { 9 | 10 | in := &QueryCreateMarketEvents{ 11 | []CreateMarketEvent{ 12 | CreateMarketEvent{ 13 | ID: "111", 14 | Timestamp: "1343243343", 15 | Outcomes: []string{ 16 | "aaa", 17 | "bbb", 18 | }, 19 | }, 20 | }, 21 | } 22 | out, _ := in.ToJsonString() 23 | t.Logf("resp: type=%v, out=%v", reflect.TypeOf(out), out) 24 | } 25 | 26 | func TestQueryCreateMarketEvents_FromJson(t *testing.T) { 27 | raw := ` 28 | { 29 | "CreateMarketEvents": 30 | [ 31 | { 32 | "ID":"111", 33 | "Timestamp":"1343243343", 34 | "MarketCreator":"Creator", 35 | "Outcomes":["aaa","bbb"], 36 | "MaxPrice":"22", 37 | "MinPrice":"33", 38 | "Topic":"", 39 | "MarketCreationFee":"", 40 | "Block":"", 41 | "Address":"", 42 | "Universe":"", 43 | "Market": { 44 | "ID":"", 45 | "Description":"", 46 | "MarketType":"", 47 | "ExtraInfoRaw":"", 48 | "Status":"" 49 | } 50 | } 51 | ] 52 | } 53 | ` 54 | 55 | item := new(QueryCreateMarketEvents) 56 | err := item.FromJson([]byte(raw)) 57 | t.Logf("FromJson: %+v, err: %v", item, err) 58 | } 59 | 60 | func TestQueryFinalizeMarketEvents_ToJsonString(t *testing.T) { 61 | 62 | } 63 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/internal/dao/mq/block.go: -------------------------------------------------------------------------------- 1 | package mq 2 | 3 | import ( 4 | "github.com/better-go/pkg/mq/rabbitmq" 5 | ) 6 | 7 | // block: 8 | type BlockQueue struct { 9 | g *ConnGroup 10 | } 11 | 12 | func newBlockQueue(g *ConnGroup) *BlockQueue { 13 | return &BlockQueue{g: g} 14 | } 15 | 16 | // CreateMarketEvents 17 | func (m *BlockQueue) PublishCreateMarketEvents(message string) error { 18 | queueName := "CreateMarketEventsQueue" 19 | return m.publish(message, queueName) 20 | } 21 | 22 | // FinalizeMarketEvents 23 | func (m *BlockQueue) PublishFinalizeMarketEvents(message string) error { 24 | queueName := "FinalizeMarketEventsQueue" 25 | return m.publish(message, queueName) 26 | } 27 | 28 | // pub: 29 | func (m *BlockQueue) publish(message string, queueName string) error { 30 | exchangeName := "BlockExchange" 31 | return m.g.cli.Publish( 32 | &rabbitmq.Exchange{ 33 | Name: exchangeName, 34 | Type: "direct", 35 | Durable: false, 36 | AutoDelete: false, 37 | Internal: false, 38 | NoWait: false, 39 | Args: nil, 40 | }, 41 | &rabbitmq.Queue{ 42 | Name: queueName, 43 | Durable: true, 44 | AutoDelete: false, 45 | Exclusive: false, // 是否具有排他性 46 | NoWait: false, // 是否阻塞 47 | Args: nil, // 额外属性 48 | }, 49 | queueName, 50 | message, 51 | true, 52 | ) 53 | } 54 | -------------------------------------------------------------------------------- /mono-repo/go-zero/{{cookiecutter.go_module_name}}/app/basic/demo/proto/model/graphql/graph_test.go: -------------------------------------------------------------------------------- 1 | package graphql 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestQueryCreateMarketEvents_ToJsonString(t *testing.T) { 9 | 10 | in := &QueryCreateMarketEvents{ 11 | []CreateMarketEvent{ 12 | CreateMarketEvent{ 13 | ID: "111", 14 | Timestamp: "1343243343", 15 | Outcomes: []string{ 16 | "aaa", 17 | "bbb", 18 | }, 19 | }, 20 | }, 21 | } 22 | out, _ := in.ToJsonString() 23 | t.Logf("resp: type=%v, out=%v", reflect.TypeOf(out), out) 24 | } 25 | 26 | func TestQueryCreateMarketEvents_FromJson(t *testing.T) { 27 | raw := ` 28 | { 29 | "CreateMarketEvents": 30 | [ 31 | { 32 | "ID":"111", 33 | "Timestamp":"1343243343", 34 | "MarketCreator":"Creator", 35 | "Outcomes":["aaa","bbb"], 36 | "MaxPrice":"22", 37 | "MinPrice":"33", 38 | "Topic":"", 39 | "MarketCreationFee":"", 40 | "Block":"", 41 | "Address":"", 42 | "Universe":"", 43 | "Market": { 44 | "ID":"", 45 | "Description":"", 46 | "MarketType":"", 47 | "ExtraInfoRaw":"", 48 | "Status":"" 49 | } 50 | } 51 | ] 52 | } 53 | ` 54 | 55 | item := new(QueryCreateMarketEvents) 56 | err := item.FromJson([]byte(raw)) 57 | t.Logf("FromJson: %+v, err: %v", item, err) 58 | } 59 | 60 | func TestQueryFinalizeMarketEvents_ToJsonString(t *testing.T) { 61 | 62 | } 63 | -------------------------------------------------------------------------------- /mono-repo/rs/{{cookiecutter.repo_name}}/deploy/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Deploy: 4 | 5 | - 部署/运维相关配置脚本 6 | 7 | 8 | ## introduction: 9 | 10 | - local: 本地开发环境: 基于 docker + docker-compose 11 | - staging: 预发布环境: 基于 docker or k8s 12 | - production: 生产环境: 基于 13 | 14 | 15 | 16 | ## reference: 17 | 18 | > docker: 19 | 20 | - https://docs.docker.com/engine/install/ 21 | - https://docs.docker.com/engine/install/ubuntu/ 22 | - https://docs.docker.com/compose/install/ 23 | 24 | > Kubernetes (K8s): 25 | 26 | - https://github.com/kubernetes/kubernetes 27 | - https://github.com/k3s-io/k3s 28 | 29 | 30 | > terraform: 31 | 32 | - https://github.com/hashicorp/terraform 33 | - examples: 34 | - https://github.com/hashicorp/terraform-guides 35 | - https://github.com/hashicorp/terraform-guides/blob/master/infrastructure-as-code/hashistack/quick-start/terraform-aws/README.md 36 | - https://github.com/futurice/terraform-examples 37 | - https://github.com/futurice/terraform-examples/blob/master/aws/aws_ec2_ebs_docker_host/README.md 38 | 39 | > docker-compose + dockerfile: 40 | 41 | - https://github.com/service-mesh/devops 42 | - https://github.com/service-mesh/dockerfile 43 | 44 | 45 | 46 | ## local: 47 | 48 | - 本地开发环境: 49 | - 启动 docker 容器: 50 | 51 | ```bash 52 | 53 | cd deploy/local 54 | 55 | make run.xxx 56 | 57 | ``` 58 | 59 | 60 | ## staging: 61 | 62 | - 预发布环境: 63 | 64 | 65 | ## production: 66 | 67 | - 生产环境: 68 | -------------------------------------------------------------------------------- /mono-repo/go-kratos/{{cookiecutter.repo_name}}/deploy/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Deploy: 4 | 5 | - 部署/运维相关配置脚本 6 | 7 | 8 | ## introduction: 9 | 10 | - local: 本地开发环境: 基于 docker + docker-compose 11 | - staging: 预发布环境: 基于 docker or k8s 12 | - production: 生产环境: 基于 13 | 14 | 15 | 16 | ## reference: 17 | 18 | > docker: 19 | 20 | - https://docs.docker.com/engine/install/ 21 | - https://docs.docker.com/engine/install/ubuntu/ 22 | - https://docs.docker.com/compose/install/ 23 | 24 | > Kubernetes (K8s): 25 | 26 | - https://github.com/kubernetes/kubernetes 27 | - https://github.com/k3s-io/k3s 28 | 29 | 30 | > terraform: 31 | 32 | - https://github.com/hashicorp/terraform 33 | - examples: 34 | - https://github.com/hashicorp/terraform-guides 35 | - https://github.com/hashicorp/terraform-guides/blob/master/infrastructure-as-code/hashistack/quick-start/terraform-aws/README.md 36 | - https://github.com/futurice/terraform-examples 37 | - https://github.com/futurice/terraform-examples/blob/master/aws/aws_ec2_ebs_docker_host/README.md 38 | 39 | > docker-compose + dockerfile: 40 | 41 | - https://github.com/service-mesh/devops 42 | - https://github.com/service-mesh/dockerfile 43 | 44 | 45 | 46 | ## local: 47 | 48 | - 本地开发环境: 49 | - 启动 docker 容器: 50 | 51 | ```bash 52 | 53 | cd deploy/local 54 | 55 | make run.xxx 56 | 57 | ``` 58 | 59 | 60 | ## staging: 61 | 62 | - 预发布环境: 63 | 64 | 65 | ## production: 66 | 67 | - 生产环境: 68 | --------------------------------------------------------------------------------