--go_out: protoc-gen-go: plugins are not supported;

記錄問題:--go_out: protoc-gen-go: plugins are not supported;

標籤(空格分隔): grpc,protoc-gen-go


grpc官網:https://grpc.io/docs/languages/go/quickstart/
官網寫的要安裝以下:

$ go install google.golang.org/protobuf/cmd/[email protected]
$ go install google.golang.org/grpc/cmd/[email protected]

之前生成pb文件的命令是:

protoc --go_out=plugins=grpc:. --go_opt=paths=source_relative ./user.proto

但是這個會報錯:

--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC

See https://grpc.io/docs/languages/go/quickstart/#regenerate-grpc-code for more information.

一直提示這個不存在protoc-gen-go,實際明明是有的,若果使用官方文檔寫的命令是可以成功的

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

這個命令會生成兩個pb文件,如果你還想用之前的命令,就需要換一個protoc-gen-go
github地址:https://github.com/golang/protobuf

go install github.com/golang/protobuf/protoc-gen-go

這樣就可以用之前的命令來生成pb文件,並且是在一個文件裏

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章