grpc-web
grpc-web copied to clipboard
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC`
- Found your repo researching
grpc-websolutions to setup an Angular (or Vue) project with Go + gRPC. - Setup a new Golang environment, test with other Go projects, seems to work fine for normal Go projects
- Pulled this repo
- Changed directory down into the
client/grpc-web-react-exampleand read the Readme.md - Ran
npm install, no errors - Ran
npm start, error:
[email protected] start
npm run build:proto && concurrently --kill-others "go run go/exampleserver/exampleserver.go" "npm run webpack-dev"
[email protected] build:proto
./protogen.sh
Optional env var GOBIN is not set; using default derived from GOPATH as: "/Users/<myusername>/go/bin"
./protogen.sh: line 24: cd: ../../vendor/github.com/golang/protobuf: No such file or directory
Compiling protobuf definitions
protoc-gen-go: unable to determine Go import path for "examplecom/library/book_service.proto"
Please specify either:
• a "go_package" option in the .proto source file, or
• a "M" argument on the command line.
- Ran
go mod vendor - Added:
option go_package = "./";@ line 4 ofproto/examplecom/library/book_service.proto - Now I get the error:
[email protected] start
npm run build:proto && concurrently --kill-others "go run go/exampleserver/exampleserver.go" "npm run webpack-dev"
[email protected] build:proto
./protogen.sh
Optional env var GOBIN is not set; using default derived from GOPATH as: "/Users/jamesbenson/go/bin"
make: *** No rule to make target `install'. Stop.
Compiling protobuf definitions
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC`
Looking to strongly advocate for using Go+gRPC at my job, but i've had trouble finding useable projects to learn from. This looked like the "defacto" project to learn from, however the documentation only appears to be "Feature Documentation" and it doesn't appear to be up-to-date?
Has Improbable moved away from Go+gRPC (or simply gRPC in general)?
Cheers!
Hi, thanks for your issue! First, let me make clear that I don't speak for Improbable, I never worked there, and I don't know what they do internally. This repository has bitrot a bit since it was first created, and the protobuf generation in particular is an area that could use some work. I'm sorry you had a bad experience, but I would generally recommend not using this repository as a model for anything right now.
That said, Go+gRPC+gRPC-web is a really great combination, whether you use the client/proxy from this repository or not. I don't know if I have any good modern example projects to point to (I might create one, separate from this project 🤔), but generally it's "just" a matter of getting the generation working and then hosting the client somewhere where you can reach the server. I have an example that uses a different client here: https://github.com/johanbrandhorst/grpcweb-example/blob/master/main.go, but it's also a bit old so I wouldn't use it for anything other than inspiration.
Your immediate problem is because you're using a different version of protoc-gen-go than this repository does. protoc-gen-go installed from https://pkg.go.dev/google.golang.org/protobuf/ do not support using the plugins=grpc parameter. You could try running go install github.com/golang/protobuf/protoc-gen-go from the root of this repository and it should give you the right version (I think)? We should just replace all of that with a more reproducible scenario, but unfortunately this repository hasn't really seen the love it deserves for a while.
I went and made an example repo of using Go, React/TS and gRPC-Web - it uses a different client library, but it is using our proxy in the backend: https://github.com/johanbrandhorst/grpc-web-go-react-example.
I went and made an example repo of using Go, React/TS and gRPC-Web - it uses a different client library, but it is using our proxy in the backend: https://github.com/johanbrandhorst/grpc-web-go-react-example.
Thanks for all of the feedback and info Johan! I'll definitely give your repo a dig!