6

This is not a repeat of this question:

what should be the values of GOPATH and GOROOT?

I don't want to know what the values should be. I want to know what I should see when I type ls $GOROOT or ls $GOPATH into console. I'm pretty sure I set things up wrong following a tutorial almost a year ago, and I want to be able to confirm that these two are pointing to where they should be by simply checking that what they point to looks right.

Here's where I am right now. It looks like $GOROOT is pointing nowhere. I'm pretty sure it should be pointing at usr/local/go, but it would be a lot easier to confirm if I knew what the expected result of ls $GOROOT is supposed to be.

As for $GOPATH I'm not totally sure if my "workspace" is where all my go code is, or maybe just the github stuff, or maybe the particular folder I'm working within. I know it's supposed to point to my "work space," but I don't know what that work space I'm looking for looks like.

Sephs-MBP:ThumbzArt seph$ $GOROOT
Sephs-MBP:ThumbzArt seph$ $GOPATH
-bash: /Users/seph/code/golang: is a directory
Sephs-MBP:ThumbzArt seph$ ls $GOROOT
Bman.jpg            README.md           ThumbzArt.sublime-workspacescripts              thumbzart.go
LICENSE.md          ThumbzArt.sublime-project   public              templates           ticktock.go
Sephs-MBP:ThumbzArt seph$ $GOPATH
-bash: /Users/seph/code/golang: is a directory
Sephs-MBP:ThumbzArt seph$ ls $GOPATH
-   bin p   pkg src
Sephs-MBP:ThumbzArt seph$ ls /usr/local/go
AUTHORS     CONTRIBUTORS    PATENTS     VERSION     bin     doc     lib     pkg     src
CONTRIBUTING.md LICENSE     README.md   api     blog        favicon.ico misc        robots.txt  test
Sephs-MBP:ThumbzArt seph$ 

I know this question seems ridiculous, but it's hard to confirm things for which you have no expected results.

Thank you

Sephs-MBP:streak seph$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/seph/code/golang"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT=""
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

Sephs-MBP:streak seph$ go version
go version go1.5.2 darwin/amd64

Sephs-MBP:streak seph$ which go
/usr/local/go/bin/go
Community
  • 1
  • 1
Seph Reed
  • 8,797
  • 11
  • 60
  • 125
  • 2
    Don't set GOROOT. Once you set GOPATH, the go tools with create what's necessary. You don't need to do anything extra. – JimB Mar 10 '16 at 15:54
  • What "silent failure" are you getting? We need to know what the problem actually is you want to solve. – JimB Mar 10 '16 at 15:58
  • I'm getting a silent failure, and I haven't touched anything since my last use. I know that I used to have a little script I would copy and paste that set $GOPATH or $GOROOT or $PATH or maybe all three. But with no error being thrown, it's really hard to tell what's missing. – Seph Reed Mar 10 '16 at 15:59
  • There are no "silent failures" from the go tool if it does anything at all. Use the `-x` option of you want to see all the commands executed. – JimB Mar 10 '16 at 16:02
  • okay. nothing happens. it just hangs there. And I'm okay with figuring things out from there. I just wanted to know what the expected results of `ls $GOPATH` and `ls $GOROOT` are – Seph Reed Mar 10 '16 at 16:03
  • I'm not expecting you guys to fix my problem for me. I'm asking for some confirmation on data. A confirmation which should probably be easy to find. – Seph Reed Mar 10 '16 at 16:04
  • it appears that `ls $GOROOT` is different from `ls usr/local/go` though `go env` says `GOROOT="/usr/local/go"` – Seph Reed Mar 10 '16 at 16:14
  • 1
    Ofc it differs: `$GOROOT` ist not set so `ls $GOROOT` outputs the content of your working dir. Is go really the go from /usr/local/go (`which go`). Can you build your sourcefile? – 0x434D53 Mar 10 '16 at 16:27
  • 1
    By the way: What does your program do? Sure that your program does exit? – 0x434D53 Mar 10 '16 at 16:30
  • I added `which go`. I'm not sure which sourcefile you're speaking of. I have a simple `helloworld.go` that ran fine. I have another project which returns no errors and just kind of hangs when I run `go run thumbzart.go [-x]`. Bot of these projects worked fine last time I touched them. The program hosts a website. Is there another source file I should build? – Seph Reed Mar 10 '16 at 16:31
  • 1
    What i think: go is setup ok, thumbzart.go not. – 0x434D53 Mar 10 '16 at 16:35
  • That's what I think too. I just hadn't touched thumbzart.go, and I used to do something with the paths every time I ran it. I wanted to confirm it wasn't my set up, and that seems to be confirmed. Thank you for your help. – Seph Reed Mar 10 '16 at 16:37
  • 1
    See also: [How to show an environment variable's current value?](http://unix.stackexchange.com/questions/244323/how-to-show-an-environment-variables-current-value) on [unix.SE] Stack Exchange – Ilmari Karonen Apr 01 '16 at 20:01

1 Answers1

-4

EDIT: Another very useful feature I just stumbled across is this: go help gopath. This should have probably been somebodies answer.

The folder $GOPATH points to should like this:

Sephs-MBP:streak seph$ ls $GOPATH
-   bin p   pkg src

$GOROOT, on the other hand, will yield unexpected results if you use ls $GOROOT as compared to ls $GOPATH. This is because $GOROOT is not set within this context, I think.

Sephs-MBP:helloworld seph$ ls $GOROOT
helloworld.go

If you use go env you'll see the true nature of $GOROOT

Sephs-MBP:streak seph$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/seph/code/golang"
GORACE=""
GOROOT="/usr/local/go"            //this is where it actually points
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT=""
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-    arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

And if you get the result of $GOROOT from go env and do ls you should see something like this:

Sephs-MBP:streak seph$ ls /usr/local/go
AUTHORS     CONTRIBUTORS    PATENTS     VERSION     bin     doc         lib     pkg     src
CONTRIBUTING.md LICENSE     README.md   api     blog        favicon.ico misc        robots.txt  test

If all of these things check out, then your $GOPATH and $GOROOT are properly set.

Seph Reed
  • 8,797
  • 11
  • 60
  • 125