johanbrandhorst / grpcweb-example

An example implementation of a GopherJS client and a Go server using the Improbable gRPC-Web implementation
MIT License
95 stars 12 forks source link

cannot find package "github.com/gorilla/websocket" in any of: #19

Closed timotheecour closed 6 years ago

timotheecour commented 6 years ago

go run main.go main.go:14:2: cannot find package "github.com/gorilla/websocket" in any of: /Users/timothee/homebrew/Cellar/go/1.10.2/libexec/src/github.com/gorilla/websocket (from $GOROOT) /Users/timothee/go/src/github.com/gorilla/websocket (from $GOPATH)

I had to do:

go get github.com/gorilla/websocket
go get github.com/improbable-eng/grpc-web/go/grpcweb
go get github.com/johanbrandhorst/grpcweb-example/client/compiled
go get github.com/lpar/gzipped
go get github.com/sirupsen/logrus

could these instructions be added to readme? are these the correct instructions?

johanbrandhorst commented 6 years ago

That's weird, it's definitely in the vendor directory. How did you check it out?

johanbrandhorst commented 6 years ago

I see you edited your original query, no, that is not the correct thing to be doing, if you've cloned the repo with the vendor folder everything should build automatically. Can you tell me how you cloned the repo?

timotheecour commented 6 years ago
cd mydir
git clone https://github.com/johanbrandhorst/grpcweb-example
cd grpcweb-example
go run main.go

NOTE: I'm on OSX go version go version go1.10.2 darwin/amd64

echo $GOROOT zsh: GOROOT: parameter not set echo $GOPATH zsh: GOPATH: parameter not set

/cc @johanbrandhorst I'm seeing that 'vendor' is not mentioned in 'main.go', how could it find it? I'm seeing it mentioned in Makefile, but README says to run go run main.go BEFORE any reference to make

EDIT

make
protoc -I. -Ivendor/ proto/library/book_service.proto \
        --gopherjs_out=plugins=grpc,Mgoogle/protobuf/timestamp.proto=github.com/johanbrandhorst/protobuf/ptypes/timestamp:$GOPATH/src \
        --go_out=plugins=grpc:$GOPATH/src
protoc-gen-gopherjs: program not found or is not executable
--gopherjs_out: protoc-gen-gopherjs: Plugin failed with status code 1.
johanbrandhorst commented 6 years ago

The vendor directory is located in the same folder as main.go. I'm wondering if you perhaps cloned the repo outside of teh $GOPATH? You'll need to make sure you clone the repo to the appropriate path in the $GOPATH structure.

How about you try and go-get the project instead?

$ go get -u github.com/johanbrandhorst/grpcweb-example

Then you should be able to run grpcweb-example and it will host the site for you. It will also clone it into the right place ($GOPATH/src/github.com/johanbrandhorst/grpcweb-example).

timotheecour commented 6 years ago

The vendor directory is located in the same folder as main.go

right, but main.go references github.com/gorilla/websocket, not vendor/github.com/gorilla/websocket , so not sure how it could guess to look inside vendor

I'm wondering if you perhaps cloned the repo outside of teh $GOPATH

as mentioned above, my GOPATH is empty

How about you try and go-get the project instead?

just did, it did create /Users/timothee/go/bin/grpcweb-example , woohoo! (also indeed creates under ~/go/src/github.com/johanbrandhorst/grpcweb-example/) however: it'd be nice to not have to do this (eg if i don't want to affect what's inside ~/go, or if I want to work on multiple forks of grpcweb-example) and it'd build locally wherever I git clone to (may i need to set GOPATH to something ? the clone repo root folder?)

johanbrandhorst commented 6 years ago

The last error is because you need to generate some self-signed certs first:

$ make generate_cert

https://github.com/johanbrandhorst/grpcweb-example/blob/master/Makefile#L18.

You'll need to run the binary from somewhere that has access to those generated certs, like the root of the repository (~/go/src/github.com/johanbrandhorst/grpcweb-example/). Or, you can specify your own cert and key if you have those available.

On the point about not modifying the $GOPATH, I'm afraid you're out of luck as long as you want to use Go ;). There are various tools for managing different versions of libraries, but it's definitely outside the scope of this repo. I encourage you to google around and learn about the $GOPATH. This will also explain the concept of the vendor folder.

I'm going to close this as the root of the issue was the unorthodox cloning of the repo. Sorry if this is your first Go project, but you simply need to be using the GOPATH for anything to be working as expected.

timotheecour commented 6 years ago

$ make generate_cert

this did work, thanks; but then navigating to https://localhost:10000/ gave a `your connection is not private error' .... :-( (network is wifi from my phone on which i'm tethering, not sure if that's relevant)

will try with generating my own cert and key

johanbrandhorst commented 6 years ago

Yeh, it's a self signed certificate. You're welcome to use whichever certificate you like, and the example also supports using Lets Encrypt. It's running on https://grpcweb.jbrandhorst.com using Let's Encrypt for certificate issuing.