In depth analysis of micro service efficiency tool goctl


This article is based on an qiansong's video sharing. The video playback address is as follows:

Origin of goctl

1. birth of goctl

The earliest function of goctl is to solve the problem of GRPC intranet debugging. About 2019, in our production environment, rpc is isolated from the intranet and cannot be accessed through the Internet. In order to quickly mock some online RPC client requests, we simply realized the generation of the first version of the code. The main purpose is to access the RPC Server for some debugging.

2. why do you need goctl?

  • Reduce communication costs

    Communication is a form of information exchange through team collaboration. There are many ways of communication, such as meeting communication, document communication and chat communication. I believe that no matter which way, communication is the most difficult link in the team. Meeting communication takes up a lot of time. Sometimes it starts in half an hour. Document communication also takes up a lot of time to conceive and write large documents. In the end, it may not express the expected goal, Online chat requires both parties to exchange information online. Of course, the information exchanged here refers to some contents in development, such as interface information, deployment information, etc.

  • Reduce team coupling

    With communication, the coupling of collaboration between teams can not be avoided. For example, in front-end and back-end development, the biggest coupling is interface coupling. After the front-end completes the specified UI drawing, it needs to wait for the back-end interface to be deployed to the corresponding environment to realize function debugging. During this period, the front-end team resources will be greatly wasted, which will also lead to problems such as project delay.

  • Improve development efficiency

    In addition to communication costs and team coupling, each team also spends a lot of time doing repetitive work during project development. For example, when developing a new function, we need to define interfaces, write interface documents, code preparation, business development, model files, write dockerfiles, and write k8s yaml files. We can improve in each link, Let users focus their real time on business development.

  • Reduce error rate

    In the previous development practice, the problem of incomplete implementation of grpc server often occurs, and the implementation class of grpc server often fails to compile; In addition, the development of database query layer code, the preparation of sql statements with many parameters and few parameters, and parameter dislocation are difficult to find in the compilation process. Generally, they can only be found in QA, and even lead to online problems.

3. how to understand the development specification?

Development specifications include coding specifications, engineering specifications, submission specifications, code review specifications, deployment specifications, etc. if the development specifications are unified within the team, the benefits can be imagined. For example, if your company does not have unified development specifications, you need to do some cross departmental collaboration or support. A new development environment makes you flinch, and you have the idea of conflict before you start, This is not against the original intention of support.

4. how to understand engineering efficiency?

Engineering efficiency. To understand engineering efficiency, you can first look at the definition of "efficiency":

Efficiency is the amount of work done per unit of time

The goal of efficiency is to be fast, but fast is not efficiency. In other words, it means to complete high-quality work in unit time. This is the goal we want to pursue. Then, engineering efficiency is to "shorten the distance from development to online"

2, Installation and function introduction of goctl

1. introduction

  • goctl definition

    The definition of goctl, to be exact, is positioning. It can be understood as a code generation scaffold. Its core idea is to complete the code generation function through syntax analysis, semantic analysis and data-driven implementation of DSL. It aims to help developers improve their development efficiency from the perspective of engineering efficiency.

  • Problems solved

    • Improve development efficiency: the code generation of goctl covers multiple languages such as Go, Java, Android, iOS, TS, etc. through goctl, the code of each end can be generated with one click, allowing developers to focus on business development.
    • Reduce communication costs: use zero API instead of API documents, and each end generates code centered on zero API. There is no need to transfer interface information through meetings and API documents.
    • Reduce coupling: in previous development practice, before goctl, we used traditional API documents as the carrier for interface information transmission, and then conducted a second review through meetings. We all know that in front-end development, in addition to UI drawing, UI joint debugging is also the work of front-end development. If more active front-end developers, they may use some scaffolding or mock some data to conduct UI joint debugging, On the contrary, there are case s of waiting in place for the back-end deployment before joint commissioning. The reason is that it takes too long to write mock data. If the development progress of the front-end is ahead of that of the back-end, the front-end can only wait in place quietly during the deployment of the back-end to the environment. This is not only a waste of resources, but also a delay in the project progress. With the zero API, The front end can use goctl to generate an appropriate amount of mock data for UI joint debugging.
  • Development history

The development history of goctl can be briefly reviewed. Select several iconic functions to tell us about!

The first is goctl rpc. The first version of goctl rpc is the prototype of goctl. It is mainly used to generate client code for rpc debugging. The details will not be expanded. The development of goctl rpc has gone through many twists and turns. The most impressive one should be the transformation from goctl rpc proto to goctl rpc Protocol. During this period, corresponding changes were made to solve many problems. The specific details are shared in the section of rpc code generation and use. In fact, one of the most impressive functions for me is goctl model, which is a starting point for me to start maintaining goctl, It is also a solution that I have mined from the practice of business development. After all, I am still "lazy". I remember that I developed a business module at that time. Because the business is relatively large, there are many data tables that need to be created. Before goctl, I had to code them manually. I can still remember this part. I spent only one day writing the model file. Because I have no habit of using orm, this sql is completely a bare sql statement, After the service started running, I found that there were many errors in transferring sql parameters, which were basically the problem of more parameters and less parameters. In addition, I was very troubled by the maintenance of cache related logic every time an index was added or a field was changed. Therefore, in combination with the development best practices at that time, I entrusted this work to goctl according to whether it was cached or not. The first version of goctl model was mainly generated as a web version, which was later integrated into goctl, This has brought great development efficiency benefits to my follow-up development.

  • Looking ahead

    goctl integrates many functions. It basically focuses on code generation, supplemented by development specifications. goctl focuses on zero api code generation. Therefore, in the future, the construction of zero API will become our focus:

    • Transformation of ast: replacing the heavy antlr4 can solve the problems that many people do not have enough memory when installing goctl and the system architecture does not support it
    • Supported by goctl mock, decoupling dependency coupling at each end to the maximum extent

2. installation

Goctl can be installed in two ways: go get or go install, followed by docker.

go get/install

# Go before 1.16
$ GO111MODULE=on GOPROXY=,direct go get -u

# Go 1.16 and later
$ GOPROXY=,direct go install

# macOS
$ brew install goctl

# validate
$ goctl --version
goctl version 1.3.5 darwin/amd64

# View goctl
$ cd $GOPATH/bin && ls | grep "goctl"

If you execute goctl --version and prompt command not found: goctl, check whether $GOBIN is under the environment variable.


# 1. pull
$ docker pull kevinwan/goctl

# 2. ls
$ docker image ls | grep "goctl"
kevinwan/goctl        latest    7fd46843de3d   5 weeks ago    383MB

# 3. run
$ docker run -it kevinwan/goctl /bin/sh

3. function introduction

Let's take a look at the function introduction. We can list the currently supported functions through the instruction goctl --help. Maybe you didn't pay attention to this instruction when reading the document, but only used some high-frequency instructions. Since today is the special topic of goctl, we will spend some time together to familiarize you with goctl from 0 to 1.

$ goctl --help                                                       
A cli tool to generate api, zrpc, model code

goctl [command]

Available Commands:
api         Generate api related files
bug         Report a bug
completion  Generate the autocompletion script for the specified shell
docker      Generate Dockerfile
env         Check or edit goctl environment
help        Help about any command
kube        Generate kubernetes files
migrate     Migrate from tal-tech to zeromicro
model       Generate model code
quickstart  quickly start a project
rpc         Generate rpc code
template    Template operation
upgrade     Upgrade goctl to latest version

-h, --help      help for goctl
-v, --version   version for goctl

Use "goctl [command] --help" for more information about a command.

Goctl has rich functions, so it is inevitable that there are many command parameters. In addition to reading the documentation, people also make good use of the flag --help, because it will tell you the usage of each instruction or sub instruction, what parameters are required, whether the parameter type is string or boolean, required or optional. You must not guess what flag it should use. Although goctl is mainly maintained by myself, in fact, many times, Some instructions are compared with documents. There are not many feature s to update. I can't remember them. I also use --help to view the function introduction

Key presentation

goctl completion

View goctl version

$ goctl --version
goctl version 1.3.5 darwin/amd64

This section is only applicable to the reference of automatic completion setting of goctl version before 1.3.5. Version 1.3.5 and before only supports Unix like operating system, and does not support automatic completion of Windows. Please skip this section after 1.3.5

  1. Execute goctl completion -h to view the instructions
$ goctl completion --help                                
   goctl completion - generation completion script, it only works for unix-like OS

goctl completion [command options] [arguments...]

--name value, -n value  the filename of auto complete script, default is [goctl_autocomplete]

According to the help description, goctl completion supports the generation of automatic completion script file name by passing a parameter --name, but this parameter is not required. If it is not filled in, it is goctl by default_ Autocomplete file, which is located in the $GOCTLHOME directory.

  1. Execute goctl completion to generate an auto Completion Script
$ goctl completion
generation auto completion success!
executes the following script to setting shell:
echo PROG=goctl source /Users/keson/.goctl/.auto_complete/zsh/goctl_autocomplete >> ~/.zshrc && source ~/.zshrc

# perhaps
echo PROG=goctl source /Users/keson/.goctl/.auto_complete/bash/goctl_autocomplete >> ~/.bashrc && source ~/.bashrc
  1. View current shell
$ echo $SHELL                                                  
  1. Select the script execution of the corresponding shell. I call it zsh here, so the execution instructions are as follows
$ echo PROG=goctl source /Users/keson/.goctl/.auto_complete/zsh/goctl_autocomplete >> ~/.zshrc && source ~/.zshrc
  1. Restart terminal verification results
# Type goctl and press tab to view the auto completion prompt
$ goctl # tab
api            -- generate api related files
bug            -- report a bug
completion     -- generation completion script, it only works for unix-like OS
docker         -- generate Dockerfile
env            -- check or edit goctl environment
help        h  -- Shows a list of commands or help for one command
kube           -- generate kubernetes files
migrate        -- migrate from tal-tech to zeromicro
model          -- generate model code
rpc            -- generate rpc code
template       -- template operation
upgrade        -- upgrade goctl to latest version

This section is only applicable to the automatic completion setting reference of goctl version before and after 1.3.6. Please skip this section before 1.3.6

  1. If you are upgrading from 1.3.5 to 1.3.6 or later, you need to execute the following instructions to clear the automatic completion configuration of the old version. Take zsh as an example here. Otherwise, please skip this step
# Edit ~/ zshrc
$ vim ~/.zshrc
# Find the row where PROG=goctl is located and delete it
# source
$ source ~/.zshrc && rm .zcompdump*
# Restart the terminal
  1. Execute goctl completion -h to view the instructions. From the help, you can view the automatic completion of bash, fish, powershell and Zsh.
$ goctl completion --help
Generate the autocompletion script for goctl for the specified shell.
See each sub-command's help for details on how to use the generated script.

goctl completion [command]

Available Commands:
bash        Generate the autocompletion script for bash
fish        Generate the autocompletion script for fish
powershell  Generate the autocompletion script for powershell
zsh         Generate the autocompletion script for zsh

-h, --help   help for completion

Use "goctl completion [command] --help" for more information about a command.
  1. View currently used shell
$ echo $SHELL                                                  
  1. Since zsh is currently used, let's take a look at the help of automatic completion settings for zsh
$ goctl completion zsh --help
Generate the autocompletion script for the zsh shell.

If shell completion is not already enabled in your environment you will need
to enable it.  You can execute the following once:

        echo "autoload -U compinit; compinit" >> ~/.zshrc

To load completions for every new session, execute once:

#### Linux:

        goctl completion zsh > "${fpath[1]}/_goctl"

#### macOS:

        goctl completion zsh > /usr/local/share/zsh/site-functions/_goctl

You will need to start a new shell for this setup to take effect.

goctl completion zsh [flags]

-h, --help              help for zsh
--no-descriptions   disable completion descriptions

It can be seen from the above that the setting method of automatic completion is different according to the operating system. Here is macOS. Let's execute the corresponding instructions:

$ goctl completion zsh > /usr/local/share/zsh/site-functions/_goctl

Let's restart a terminal to try:

# Type goctl and press tab to view the auto completion prompt
$ goctl # tab
api         -- Generate api related files
bug         -- Report a bug
completion  -- Generate the autocompletion script for the specified shell
docker      -- Generate Dockerfile
env         -- Check or edit goctl environment
help        -- Help about any command
kube        -- Generate kubernetes files
migrate     -- Migrate from tal-tech to zeromicro
model       -- Generate model code
quickstart  -- quickly start a project
rpc         -- Generate rpc code
template    -- Template operation
upgrade     -- Upgrade goctl to latest version

Common errors

  1. goctl Error: unknown flag: --generate-goctl-completion
  2. (EVAL): 1: command not found:_ Goctl is reconfigured according to 1.3.6 automatic completion configuration

goctl migrate

Help developers seamlessly migrate from versions before 1.3.0 to any version after 1.3.0. If the go zero version used is 1.3.0 or later, this operation is not necessary.

Why do I need to migrate?

In version 1.3.0, go zero changed its organization, that is, it replaced the original tal tech organization name with zeromicro.

I now have a demonstration project awesomemigrate, which is generated from the old version of goctl. The module of the go zero of this project is

module awesomemigrate

go 1.18

require v1.2.5


Suppose we need to upgrade the go zero of the project to the latest version 1.3.3 up to now. To complete the upgrade of the project from tal tech to zeromicro, we need to ensure that the goctl version is greater than v1.3.2, and then execute the goctl migration instruction. If the goctl version is less than v1.3.2, we need to upgrade.

# 1. view the current goctl version
$ goctl --version
goctl version 1.2.5 darwin/amd64

# 2. since the goctl version is smaller than v1.3.2, you need to upgrade to the latest version. If the goctl version is already 1.3.2 or later, you do not need to upgrade
$ go install

# 3. check the migration instruction help
$ goctl migrate --help                                  
goctl migrate - migrate from tal-tech to zeromicro

goctl migrate [command options] [arguments...]

migrate is a transition command to help users migrate their projects from tal-tech to zeromicro version

--verbose, -v    verbose enables extra logging
--version value  the target release version of to migrate

# 4. enter the item to be migrated and execute the migration instruction
$ goctl migrate --version 1.3.3

# 5. verify whether the dependency has problems
$ go test .
?       awesomemigrate  [no test files]

After the migration, let's look at the module file again

module awesomemigrate

go 1.18

require v1.3.3

Search the project for the matching result of Tal tech and find that it is 0:

goctl env

goctl env is mainly used for environment detection, installation, environment parameter control and other functions. In addition, it can also view some environment information of the current goctl, so that users can report the current goctl environment according to this environment when they encounter a bug.

First, let's take a look at its instructions

$ goctl env --help                                    
goctl env - check or edit goctl environment

goctl env command [command options] [arguments...]

install  goctl env installation
check    detect goctl env and dependency tools

--write value, -w value  edit goctl environment
--help, -h               show help

goctl env supports environment viewing, parameter modification, dependency detection and installation. Let's take a look at them in turn

1. environment view

If no flag is entered, the current goctl environment is viewed.

$ goctl env                                             

The general description of the above parameters is

Parameter name Parameter type Parameter description
GOCTL_OS STRING Current operating system, common values include darwin, windows, linux, etc
GOCTL_ARCH STRING Current system architecture, common values are amd64, 386, etc
GOCTL_HOME STRING The default is ~/ goctl
GOCTL_DEBUG BOOLEAN Whether to enable the debug mode. The default value is false. It is not currently used. It is mainly used to control the debug mode in goctl development
GOCTL_CACHE STRING goctl cache directory, which mainly caches the downloaded dependent protocol, protocol Gen go, protocol Gen go grpc, etc
GOCTL_VERSION STRING Current goctl version
PROTOC_VERSION STRING The current protoc ol version, if not installed, is an empty string
PROTOC_GEN_GO_VERSION STRING Current protocol Gen go version, such as not installed or from github Empty string if com/golang/protobuf is installed before v1.3.2
PROTO_GEN_GO_GRPC_VERSION STRING The current protocol Gen go grpc version is an empty string if it is not installed
2. modify parameters

For example, we put GOCTL_DEBUG is modified to true

# Before modification
$ goctl env | grep 'GOCTL_DEBUG'

# Modify GOCTL_DEBUG is true
$ goctl env -w GOCTL_DEBUG=true

# After modification
goctl env | grep 'GOCTL_DEBUG'
3. dependent detection / installation

Let's check whether my current dependencies are installed. The current dependency detection contents are protocol, protocol Gen go, and protocol Gen go grpc

# Let's check the dependency installation
$ goctl env check --verbose                              
[goctl-env]: preparing to check env

[goctl-env]: looking up "protoc"
[goctl-env]: "protoc" is not found in PATH

[goctl-env]: looking up "protoc-gen-go"
[goctl-env]: "protoc-gen-go" is not found in PATH

[goctl-env]: looking up "protoc-gen-go-grpc"
[goctl-env]: "protoc-gen-go-grpc" is not found in PATH

[goctl-env]: check env finish, some dependencies is not found in PATH, you can execute
command 'goctl env check --install' to install it, for details, please execute command
'goctl env check --help'

# Installation dependency has 2 modes
# Mode 1
# $ goctl env check --install --force --verbose

# Mode II
$ goctl env install --verbose -f                       
[goctl-env]: preparing to check env

[goctl-env]: looking up "protoc"
[goctl-env]: "protoc" is not found in PATH
[goctl-env]: preparing to install "protoc"
[goctl-env]: "protoc" is already installed in "/Users/keson/go/bin/protoc"

[goctl-env]: looking up "protoc-gen-go"
[goctl-env]: "protoc-gen-go" is not found in PATH
[goctl-env]: preparing to install "protoc-gen-go"
[goctl-env]: "protoc-gen-go" is already installed in "/Users/keson/go/bin/protoc-gen-go"

[goctl-env]: looking up "protoc-gen-go-grpc"
[goctl-env]: "protoc-gen-go-grpc" is not found in PATH
[goctl-env]: preparing to install "protoc-gen-go-grpc"
[goctl-env]: "protoc-gen-go-grpc" is already installed in "/Users/keson/go/bin/protoc-gen-go-grpc"

[goctl-env]: congratulations! your goctl environment is ready!

goctl rpc

First, let's take a look at the help of the instruction

goctl rpc -h                                                       
Generate rpc code

goctl rpc [flags]
goctl rpc [command]

Available Commands:
new         Generate rpc demo service
protoc      Generate grpc code
template    Generate proto template

--branch string   The branch of the remote repo, it does work with --remote
-h, --help            help for rpc
--home string     The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
--o string        Output a sample proto file
--remote string   The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
The git repo directory must be consistent with the directory structure

Use "goctl rpc [command] --help" for more information about a command.

The instruction provides three sub instructions. new is to quickly create a zrpc service, protoc is to generate zrpc code according to the proto description file, and template is to quickly generate a proto template. We will focus on the goctl RPC Protocol instruction to see the instructions for the use of goctl RPC Protocol:

goctl rpc protoc -h                                              
Generate grpc code

goctl rpc protoc [flags]

goctl rpc protoc xx.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=.

--branch string     The branch of the remote repo, it does work with --remote
-h, --help              help for protoc
--home string       The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
--remote string     The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
The git repo directory must be consistent with the directory structure
--style string      The file naming format, see [] (default "gozero")
-v, --verbose           Enable log output
--zrpc_out string   The zrpc output directory

How to use goctl rpc Protocol? Why is there --go in the example_ Out, -go grpc_ Out parameter, but you don't see the introduction when viewing help? At present, let's understand this first. Let's put aside goctl. What are the instructions when generating grpc code according to the official protocol? What flags will be used? For the code generation of zrpc, you can understand that goctl generates zrpc only by adding goctl rpc prefix and some goctl flags required for generating zrpc on the basis of generating grpc code instructions. For the related parameters of protocol and plug-ins protocol Gen go and protocol Gen grpc go, goctl only inherits. It is unnecessary to describe them again in help, Later, when analyzing the source code, we can explain some of the design and considerations in detail. Next, we will use an example to demonstrate it. Suppose we have a green Proto file. Aside from goctl, the instructions we need to execute to generate grpc code are as follows:

If you do not know how the grpc code is generated, please refer to the official documentation for this advice

# Go to greet Directory of proto
$ protoc greet.proto --go_out . --go-grpc_out .
$ tree
├── greet.proto
└── pb
├── greet.pb.go
└── greet_grpc.pb.go

Then, according to the introduction of goctl RPC Protocol above, the instructions for generating zrpc code should be

# There is one more --zrpc_out specifies the output directory of the zrpc code
$ goctl rpc protoc greet.proto --go_out=. --go-grpc_out=. --zrpc_out=. --verbose
[goctl-env]: preparing to check env

[goctl-env]: looking up "protoc"
[goctl-env]: "protoc" is installed

[goctl-env]: looking up "protoc-gen-go"
[goctl-env]: "protoc-gen-go" is installed

[goctl-env]: looking up "protoc-gen-go-grpc"
[goctl-env]: "protoc-gen-go-grpc" is installed

[goctl-env]: congratulations! your goctl environment is ready!
[command]: protoc greet.proto --go_out . --go-grpc_out .
$ tree
├── etc
│   └── greet.yaml
├── go.mod
├── greet
│   └── greet.go
├── greet.go
├── greet.proto
├── internal
│   ├── config
│   │   └── config.go
│   ├── logic
│   │   └── pinglogic.go
│   ├── server
│   │   └── greetserver.go
│   └── svc
│       └── servicecontext.go
└── pb
├── greet.pb.go
└── greet_grpc.pb.go

8 directories, 11 files

If you need to output logs when generating code, you can add --verbose to display the logs. When generating zrpc code, goctl RPC Protocol will first detect your environment dependency. If it is not installed, it will automatically install the dependency before generating code.

4. editor plug-in

In order to improve the efficiency of writing zero API files, we have provided corresponding editor plug-ins for intellij and vscode respectively. For the introduction and use of intellij plug-ins, please refer to, For the introduction and use of vscode plug-ins, please refer to

3, Problems encountered in the use of goctl

Goctl has 13 level-1 instructions and nearly 30 level-2 instructions from the original rpc proxy function to the current version (v1.3.5). During this period, goctl has made some adjustments. Moreover, gcotl itself is moving forward very fast. It is more like groping for a faster and easier way to use. Therefore, goctl will appear unstable on the way of iteration, and we may also encounter many problems, Here is a summary of some of the issues that we have received more feedback from the community to share.

1. failed to install goctl on 386 architecture!

Description: in the source code generated by antlr, the boundary value of uint in 386 architecture is not well handled, resulting in boundary overflow

Repair version: v1.3.3

2. what version of plug-in is installed in grpc?

Description: anyone familiar with grpc should know that the plug-in protocol Gen go that generates grpc code has two warehouses under maintenance, three installation sources and two maintenance warehouses respectively:

# 1. golang
# 2. protocolbuffers

The three installation sources are

# 1. the warehouse maintained by golang is not recommended at present
# 2. maintained by protocolbuffers and currently recommended
# 3. goolge installation is actually a binary installation, and its source code is the same repository maintained by protocolbuffers

Before v.1.3.4, if you use goctl rpc proto to generate zrpc code, it is recommended to install the plug-in of the old version, that is, it is maintained by golang. Therefore, the zrpc code generated by this instruction is a thick package made by goctl to make it easy for users to generate instructions, but the resulting problem is that it is difficult to be compatible. Therefore, this instruction is not recommended.

In v.1.3.4 and later, there is no restriction on protocol Gen go. Users can freely choose different sources to install. However, it is recommended to install the version maintained by the protocolbuffer (the official document has been replaced with this), and the protocol Gen grpc go plug-in must be installed. The purpose of this is to follow the official grpc. However, users do not need to have too much psychological burden. It is troublesome to install so many dependencies, Goctl has been implemented for you. As long as you use goctl RPC Protocol to generate code, you will automatically detect dependencies and install them.

To sum up, it is recommended that users who are still using this instruction use goctl RPC Protocol as soon as possible.

3. why is The system cannot find the path specified error always prompted when generating api/zrpc code on Windows?

goctl.exe api go -api test.api -dir .
Stat : The system cannot find the path specified.

Description: the reason for this is that when go list -json -m obtains the go module, it gets a fixed value command-line-arguments. This problem has been solved in Fix, version will take effect in v1.3.6.

4. No help topic 'proto'

Description: this instruction has been removed in v1.3.4 and replaced with goctl RPC Protocol

5. zrpc code generation times go_package error

protoc-gen-go: unable to determine Go import path for "greet.proto"

Please specify either:
• a "go_package" option in the .proto source file, or
• a "M" argument on the command line.

See for more information.

--go_out: protoc-gen-go: Plugin failed with status code 1.

6. when zrpc generates code, it specifies that the output directory of pb is the main directory of the current service

the output of pb.go and _grpc.pb.go must not be the same with --zrpc_out:
pb output: /Users/keson/workspace/awesome-goctl/zwesome-zrpc/pb_in_main
zrpc out: /Users/keson/workspace/awesome-goctl/zwesome-zrpc/pb_in_main

7. why does the pb client generated by my code (without the client flag)?

This problem occurs only when the old version of goctl rpc proto generates zrpc code. The instruction has been removed so far.

8. why is the directory structure I generate different from the document presentation?

For the directory structure of the zrpc code generated by goctl RPC Protocol, there is no difference in the overall structure. The only difference is the pb output directory, which depends on the parameters you specify. The factors that control the pb output directory are go_opt, go grpc_ Opt, go_package, for details, please refer to< Protocol Buffers: Go Generated Code>.

9. why can't I highlight when I install the goctl editor plug-in

Open Golan's settings, search FileTypes, and set the api file suffix.

Project address

Welcome to go zero and star support us!

Wechat communication group

Follow the "microservice practice" official account and click the exchange group to obtain the community group QR code.

Tags: bash Go grpc

Posted by nishmgopal on Wed, 01 Jun 2022 08:03:18 +0530