go env GOPATH not reflecting $GOPATH

449 views
Skip to first unread message

burpswangy

unread,
Aug 31, 2017, 9:38:10 PM8/31/17
to golang-nuts
Debian 9.1 Stretch... using Go 1.9, go env shows GOPATH=/home/dev/go while echo $GOPATH=/home/dev/devSync/workspace.

No matter what I do, I can't get Go 1.9 to find my workspace!  What is goin' on!?

Ayan George

unread,
Aug 31, 2017, 9:40:07 PM8/31/17
to golan...@googlegroups.com
have you tried:

export GOPATH=/home/dev/devSync/workspace

burpswangy

unread,
Aug 31, 2017, 9:44:33 PM8/31/17
to golang-nuts
I did... to no avail.  I'm so confused right now, lol.  I even su root and tried doing things under there, just in case it was something user-specific causing it.  Nothing I do changes it.

burpswangy

unread,
Aug 31, 2017, 9:46:11 PM8/31/17
to golang-nuts
Wow, actually... that did work.  I was using 'set GOPATH' and not 'export GOPATH'.  I have GOPATH defined in my /etc/bash.bashrc... is there anywhere else I should be putting it?

James Bardin

unread,
Aug 31, 2017, 9:50:22 PM8/31/17
to golang-nuts


On Thursday, August 31, 2017 at 9:46:11 PM UTC-4, burpswangy wrote:
Wow, actually... that did work.  I was using 'set GOPATH' and not 'export GOPATH'.  I have GOPATH defined in my /etc/bash.bashrc... is there anywhere else I should be putting it?


You should be using a profile file for your environment variables, not bashrc. Either ~/.profile, ~/.bash_profile, or the proper global location depending on your system. 

burpswangy

unread,
Aug 31, 2017, 9:51:28 PM8/31/17
to golang-nuts
Thanks.  I actually moved it to /etc/environment... reboot... and it picked it up.  Appreciate the help, guys.

Val

unread,
Sep 2, 2017, 1:32:31 PM9/2/17
to golang-nuts
Hello burp, I'm glad you could solve your issue using 'export' in init scripts.

Note that if you choose ~/go (instead of ~/Dev/go) then you don't even need a GOPATH environment variable, it is regarded as the default gopath by most of the go ecosystem >=1.8.
This is intended to save these moderately interesting headaches to many developers, which I find great so I encourage to go with the default path.
Cheers
Val

Val

unread,
Sep 2, 2017, 1:35:06 PM9/2/17
to golang-nuts
I meant "instead of /home/dev/devSync/workspace". (Perks of replying with phone, couldn't see OP while typing.)
Reply all
Reply to author
Forward
0 new messages