4

I'm following the gRPC Quickstart tutorial for Go, https://grpc.io/docs/quickstart/go/, and have installed gRPC using the command

go get -u google.golang.org/grpc

I actually haven't defined a GOPATH environment variable:

> echo $GOPATH

which, as I understand it, means that it defaults to ~/go, or in my case /Users/kurt/go.

At the next step, I'd like to build the example by doing

cd $GOPATH/src/google.golang.org/grpc/examples/helloworld

However, I find that the directory doesn't exist, and there is also no google.golang.org directory in /Users/kurt/go/src:

~/g/src> ls *google*
fish: No matches for wildcard '*google*'. See `help expand`.
ls *google*
   ^

Should the package not be located here? That's what I understand from Where does go get install packages?.

Kurt Peek
  • 52,165
  • 91
  • 301
  • 526

3 Answers3

5

Using Go Modules, you can find 'go get' downloaded files at:

~/go/pkg/mod/cache/download

However, it should be treated like an immutable copy of the source code.

If you want a mutable copy of the source code, you should clone the repository:

git clone https://github.com/grpc/grpc-go
Everton
  • 12,589
  • 9
  • 47
  • 59
0

In your example output, you are in ~/g/arc

Go path default would be ~/go/src

I think auto complete bit ya there

David Budworth
  • 11,248
  • 1
  • 36
  • 45
  • That's actually just the way the Fish shell abbreviates paths; if I `pwd` I get `/Users/kurt/go/src` which is the expected directory. – Kurt Peek Sep 15 '19 at 05:13
0

In the end, I worked around the problem by cloning https://github.com/grpc/grpc-go which appears to contain the examples/helloworld directory I'm looking for. Still curious to hear where the package downloaded with go get is located.

Kurt Peek
  • 52,165
  • 91
  • 301
  • 526