Compiler error “protocol: command not found; * *”[ XXX. Pb. Go] error 127 “, and then search the article with the keyword” Pb. Go “& lt; How to use protobuf > in go;, It is pointed out that “1. Install protoc” and “2. Download and install protobuf go plug-in” are required. Then search the article with the keyword “install Protocol” & lt; Using protobuf > in golang;, Then search the article & lt; based on the title keyword “go protobuf install”; How to install and use protobuf in go language;, This article is very simple to install protocol, but it is version 2.6. After installation, the compiler reported an error: “unrecognized syntax identifier” proto3 “. This parser only recognizes” proto2 “.” so we have to execute “make install” and then search the chapter by referring to the keyword “install Protocol” & lt; Protobuf 3.1.0 installation examples and instructions;, But go to git website for the latest installation, and then the compiler reports the error “protocol Gen go: program not found or is not executable– go_ Out: Protocol Gen go: plug in failed with status code 1. ”
According to the article & lt; Using protobuf > in golang; To install protocol Gen go, it is said that “go install” needs to be executed after compilation, but the installation location is in the bin directory where the current directory is located, and the bin directory is not included in the environment variable, so it can’t be used. Just copy it to the same directory as the go executable. Article & lt; How to install and use protobuf in go language; It also points out that it is necessary to “write the executable path to the environment variable after the protocol Gen go compiles it”
Note that for grpc program, if message B is nested in message a defined in. Proto file, B needs to be assigned in the form of pointer when initializing A. for this, please refer to route in grpc’s examples directory_ Guide example, in route_ Several messages are defined in guide.proto file, among which message point is included in rectangle and routenot. Therefore, when defining these two variables in client file, pointer is used to assign values to the members of point type. For the message in the. Proto file, see the article in blog Garden & lt; Examples of golang grpc & gt“ Repeated means “array”