Use protoc to compile .proto files to generate go files

compile

protoc --go_out=plugins=grpc:./helloworld/ ./helloworld.proto 

Only one pb.go file will be generated, which can be used as client or server.

protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./helloworld.proto

Generate pb.g and grpc.go files in the current directory

proto --go_out=. --go-grpc_out=. helloworld.proto

Guess you like

Origin blog.csdn.net/ydl1128/article/details/127824559