3

I have a tree of golang code. I am using golang 1.5.1 on a Mac (OS X 10.11). I can successfully build my code with the following command with relative paths on the command line.

go install ./...

But, if I use an absolute path, I get an error message. E.g.,

go install `pwd`/...]

warning: "/Users/eben/src/cbq-gui/src/github.com/couchbaselabs/cbq-gui/..." matched no packages

That seems pretty odd, since "." and `pwd` should evaluate to the same thing. What am I missing? Thanks.

eben
  • 41
  • 1
  • 1
  • 4

2 Answers2

6

pwd will use the full absolute path, but the go tool expects paths relative to $gopath.

What you really want is go install github.com/couchbaselabs/cbq-gui/... most likely. Assuming your gopath is set to /Users/eben/src/cbq-gui which is a bit odd to me.

Most people use a single gopath for all their projects.

captncraig
  • 22,118
  • 17
  • 108
  • 151
  • Thank you, that did the trick! BTW, the reason for multiple GOPATHs is that we have been using go 1.4 up to now, and we were dependent on older versions of certain external packages, so for different versions of our own code we use specific GOPATHs and saved versions of the external packages. – eben Oct 27 '15 at 17:08
  • 1
    Very good. We have been solving problems like that by copying packages we depend on into the source tree for our individual main packages. I have found [govendor](https://github.com/kardianos/govendor) to be quite good for that. Then each project has their own version of their dependencies. – captncraig Oct 27 '15 at 17:11
1

You need to run go installation command in your $GOPATH("/Users/eben/src/cbq-gui/") with go mod.

$ GO111MODULE=on go get -u github.com/couchbaselabs/cbq-gui/...

I hope this helps.

Siyaram Malav
  • 4,414
  • 2
  • 31
  • 31