W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
protoc是一款用C++編寫的工具,其可以將proto文件翻譯為指定語言的代碼。在go-zero的微服務(wù)中,我們采用grpc進行服務(wù)間的通信,而grpc的編寫就需要用到protoc和翻譯成go語言rpc stub代碼的插件protoc-gen-go。
$ goctl env check -i -f --verbose
[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"
"protoc" installed from cache
[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"
"protoc-gen-go" installed from cache
[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"
"protoc-gen-go-grpc" installed from cache
[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!
protoc-x.x.x-osx-x86_64.zip
?并進入?protoc-x.x.x-osx-x86_64
? $ cd protoc-x.x.x-osx-x86_64/bin
$ mv protoc $GOPATH/bin
Tip
$GOPATH為你本機的實際文件夾地址
$ protoc --version
libprotoc x.x.x
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: