Trouble Shooting

1. goctl has already installed, but it shows command not found: goctl when executing commands.#

If you installed via go get, then goctl should be located in $GOPATH. You can check the full path with go env GOPATH, whether your goctl is in $GOPATH Whether your goctl is in $GOPATH or in another directory, the reason for the above problem is that the directory where goctl is located is not in PATH (environment variable).

2. How to call rpc#

You can refer to [rpc writing and calling] in the Quick Start (...) for this question. /advance/rpc-call), which describes the logic for using rpc calls.

3. proto uses import, how the goctl command needs to be written.#

goctl for import proto specifies BasePath provides protoc flag mapping, i.e. --proto_path, -I. goctl will pass this flag value to protoc.

4. Assuming that base.proto is introduced by main proto, why not generate base.pb.go.#

For a file like base.proto, the developer usually has a need for message reuse, and the source is not only the proto file written by the developer, but also the google.proto file. It may also come from some basic proto provided in google.golang.org/grpc, such as google/protobuf/any.proto, if generated by goctl then the point of centralizing these proto's would be lost.

5. How does the model control the cache time#

NewNodeConncan be passed with the optional parametercache.WithExpiry` to control the cache time to 1 day, for example, with the following code:

sqlc.NewNodeConn(conn,redis,cache.WithExpiry(24*time.Hour))

6. jwt forensics how to implement#

Please refer to [jwt forensics](... /advance/jwt)

7. how to use api middleware#

Please refer to [middleware](... /advance/middleware) /advance/middleware)

8. how to disable the output statistics log (stat)?#

logx.DisableStat()

9. rpc direct connection and service discovery connection mode writing#

// mode1: cluster direct connection
// conf:=zrpc.NewDirectClientConf([]string{"ip:port"}, "app", "token")
// mode2: etcd service discovery
// conf:=zrpc.NewEtcdClientConf([]string{"ip:port"}, "key", "app", "token")
// client, _ := zrpc.NewClient(conf)
// mode3: ip direct connection mode
// client, _ := zrpc.NewClientWithTarget("127.0.0.1:8888")

faq will update from time to time the problems you encounter, you are also welcome to write the common problems here via pr.

Last updated on