Git Product home page Git Product logo

p-api-1's Introduction

readme

文件夹说明

  • go.mod
  • rpc rpc服务
  • api api http调用
  • cronjob task任务
  • script 脚本
  • rmp 队列
  • model 数据库

文件夹tree说明

xxx-service
|____go.mod
|____README.md
|____rpc
| |____xxxxx
|____api
| |____xxxxx
|model
| |____xxxxx
|cronjob
| |____xxxxx
|script
| |____xxxxx
|rmp
| |____xxxxx

idea配置

自动引用mac系统的mod库

  1. 点击菜单栏 Goland
  2. Preferences
  3. Go -> Go Modules
  4. 打钩✅Enable Go modules integration
  5. 配置GOPROXY 选择 direct保存

创建mod

 go mod init 

API 规范

  1. 根目录cd api
  2. 创建api的模板buybuybuyService.api
  3. 生成api文件夹路径
goctl api go -api buybuybuyService.api -dir . -style goZero

也可以根目录下,使用makefile命令

make goctl-api

RPC 规范

  1. 根目录cd rpc
  2. 生成模板
goctl rpc template -o=buybuybuyService.proto  
  1. 编辑buybuybuyService.proto定义
    1. package 规范
    # 使用全小写
    package buybuybuycrpc
    
    1. service 规范
    service BuybuybuyRPC {}
    
  2. 生成rpc文件夹路径
goctl rpc proto -src buybuybuyService.proto -dir . -style goZero

也可以根目录下,使用makefile命令

make goctl-rpc

数据库规范

  1. 根目录cd model
goctl model mysql datasource -url="account:password(db_ip:3306)/db_name" -table="table_name"  -dir="." -style goZero 
  • 生成对应的table_name的数据库文件.go
  • 切记代码风格-style goZero

文件夹说明

无论是api/rpc生成都有对应的internal文件夹

etc配置

  1. ./etc/xxxService.yaml 配置数据库,redis,mq位置信息

内部的文件夹管理

  1. ./internal/config/config.go 配置数据库,redis,其他外部组件信息
  2. ./internal/svc/serviceContext.go 配置数据库关系,外部rpc调用关系
  3. ./internal/logic 编写代码逻辑

idea配置debug

  1. mac的idea
  2. 点击右上角的add configuration打开界面
  3. 点击左上角"+"
  4. 选择go build

以api为例(rpc一样的)

  1. package path 相对路径 eg: package path: code.wecochat.com/mesa/buybuybuy-service/api
  2. working directory 项目的绝对路径 eg: working directory: 绝对路径../buybuybuy-service/api
  3. 点击 play 或者 debug, 及运行

p-api-1's People

Contributors

mi2147 avatar

Watchers

Paul avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.