Skip to content

Extension of protoc, generating CRUD of goframe

Notifications You must be signed in to change notification settings

zcyc/protoc-gen-gf

Repository files navigation

protoc-gen-gf

Generate GoFrame business via proto file

Introduction

Workflow

  • Generate the proto file by mysql-to-proto
  • Adjust the services and messages in the proto, please don't use the PATCH method, the generator will generate CRUD for it
  • Generate the CRUD by protoc-gen-gf
  • Copy the files to the package you want to place
  • Adjust the fields of Req and Res in the api
  • Adjust the fields of Input and Output in the model
  • Adjust the functions in the logic
  • Initialize your DB and NoSQL in the cmd
  • Initialize your logic in the cmd
  • Initialize your controller in the cmd
  • Run and Test

Environment

Download clis

Download protos

  1. Create directory google in $GOPATH/src
  2. Copy google/api in googleapis to $GOPATH/src/google
  3. Copy src/google/protobuf in protobuf to $GOPATH/src/google
  4. Now, it has api and protobuf in $GOPATH/src/google

Install

macOS & Linux

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
go install github.com/zcyc/protoc-gen-gf/protoc-gen-gf-api@main \
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-controller@main \
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-logic@main \
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-model@main \
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-client@main

Windows

PowerShell

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && `
go install github.com/zcyc/protoc-gen-gf/protoc-gen-gf-api@main `
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-controller@main `
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-logic@main `
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-model@main `
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-client@main

CMD

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && ^
go install github.com/zcyc/protoc-gen-gf/protoc-gen-gf-api@main ^
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-controller@main ^
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-logic@main ^
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-model@main ^
           github.com/zcyc/protoc-gen-gf/protoc-gen-gf-client@main

Usage

macOS & Linux

protoc -I ./api -I $GOPATH/src \
       --go_out ./api --go_opt=paths=source_relative \
       --gf-api_out ./api --gf-api_opt=paths=source_relative \
       --gf-controller_out ./api --gf-controller_opt=paths=source_relative \
       --gf-logic_out ./api --gf-logic_opt=paths=source_relative \
       --gf-model_out ./api --gf-model_opt=paths=source_relative \
       --gf-client_out ./api --gf-client_opt=paths=source_relative \
       ./api/v1/article.proto

Windows

PowerShell

protoc -I ./api -I $env:GOPATH/src `
       --go_out ./api --go_opt=paths=source_relative `
       --gf-api_out ./api --gf-api_opt=paths=source_relative `
       --gf-controller_out ./api --gf-controller_opt=paths=source_relative `
       --gf-logic_out ./api --gf-logic_opt=paths=source_relative `
       --gf-model_out ./api --gf-model_opt=paths=source_relative `
       --gf-client_out ./api --gf-client_opt=paths=source_relative `
       ./api/v1/article.proto

CMD

protoc -I ./api -I %GOPATH%/src ^
       --go_out ./api --go_opt=paths=source_relative ^
       --gf-api_out ./api --gf-api_opt=paths=source_relative ^
       --gf-controller_out ./api --gf-controller_opt=paths=source_relative ^
       --gf-logic_out ./api --gf-logic_opt=paths=source_relative ^
       --gf-model_out ./api --gf-model_opt=paths=source_relative ^
       --gf-client_out ./api --gf-client_opt=paths=source_relative ^
       ./api/v1/article.proto

Demo

artcle

Thanks

About

Extension of protoc, generating CRUD of goframe

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published