我正在嘗試使用 grpc go 中的插件方法生成服務
這是我的 score.proto 檔案
syntax="proto3";
option go_package="./livescore";
service ScoreService{
rpc ListMatches(ListMatchesRequest) returns (ListMatchesResponse);
}
message ListMatchesRequest{
string country=1;
}
message MatchScoreResponse{
string score =1;
bool live=2;
}
message ListMatchesResponse{
repeated MatchScoreResponse scores=1;
}
當我運行這個命令時
protoc -I=. --go_out=. score.proto
它作業正常
RegisterScoreServiceServer但也可以按照命令生成
protoc -I=. --go-grpc_out=. score.proto
給我錯誤
protoc-gen-go-grpc: program not found or is not executable
我知道插件標志已被棄用,但是如何生成插件也是如此。它有點令人困惑,歡迎任何幫助
uj5u.com熱心網友回復:
如果您仔細查看檔案,它會提到要安裝的兩件事
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
對于您需要的第二個命令go install google.golang.org/grpc/cmd/[email protected]
也要安裝。
更多看這里
https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc#section-readme
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/429831.html
下一篇:在Golang中動態創建結構
