Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have multiple GOPATH directories?

Tags:

go

I set my GOPATH to

/Users/me/dev/go 

and I have

/Users/me/dev/go/src/client1 /Users/me/dev/go/src/client2 /Users/me/dev/go/src/client3 

and also

/Users/me/dev/client1/rails_project /Users/me/dev/client2/php_project etc. 

I don't like how in my root dev folder I'm forced to have this general "go" dir that holds many different client's go projects.

like image 333
Andrew Arrow Avatar asked Mar 15 '16 17:03

Andrew Arrow


1 Answers

Yes, GOPATH is a list of directories (like PATH). Run go help gopath for details. For example, on Linux, I have:

$ go env GOROOT="/home/peter/go" GOPATH="/home/peter/gopath:/home/peter/public/gopath" $ 

I have something similar on Windows.

Note: Linux uses : as the GOPATH list separator; Windows uses ; as the separator.

If you use go get it will default to the first directory in the list.

Run go env to check that everything is correct.

like image 77
peterSO Avatar answered Oct 19 '22 04:10

peterSO