1
votes

While following a tutorial I hit a wall when it wanted me to run godoc. It was missing.

After a bit of searching around, I discovered:

  • godoc has been changed for 1.2, so it's a separate library and binary.
  • You have to get it through "go get", which won't work without GOPATH.
  • Binary installations apparently include godoc? I installed from source, so it's not included by default.

I exported a GOPATH to my current application path /home/me/go_project/test. GOROOT was already set. (Note: GOPATH doesn't like to be set the same as GOROOT)

After that I ran "go get code.google.com/p/go.tools/cmd/godoc" and it dutifully installed the binary into my GOROOT/bin (yay!)

It also created a pkg installation under my /home/me/go_project/test/src/code.google.com/p... (Um...wat?)

I really don't need that code.google... bit under my test application; is there any reason Go would need that kept there? It doesn't alter anything in library paths or dependencies or anything, does it?

Essentially...can I just use the binary it put in GOROOT/bin and erase the stuff it put under my go_project application directory without affecting Go?

2
@MattSherman Yup, had that set up.What I've been doing is creating a /home/me/go_project/project1, with its own src/pkg/bin directories. Then go_project/project2 with /src /bin /pkg. Seems like that means separate GOPATH for each project when I'm working on them (which seemed to be endorsed in a response to a godoc bug report, where someone said they set up a GOPATH manually for their projects.)Bart Silverstrim
From my reading, under 1.2 they split how godoc is distributed when installed by source, so the binary will go into GOROOT/bin but the source/packages goes into the GOPATH you're currently working on. I didn't know if it affected something in the Go installation if I deleted the non-binary in the GOPATH part of its install (like with package management on platforms...does "go get" keep track of activity somewhere?)Bart Silverstrim
This structure means that it's also really easy to update Go from source, while accidentally not upgrading some binaries in the Go installation...this was a kind of "check for understanding" that this is what's really happening on my part.Bart Silverstrim
/src /pkg and /bin are intended for your whole Go workspace. Your individual projects live under /src.Matt Sherman

2 Answers

1
votes

Essentially...can I just use the binary it put in GOROOT/bin and erase the stuff it put under my > go_project application directory without affecting Go?

Yes. Go binaries are statically linked (almost).

0
votes

Tbe answer to your question is yes. However if you plan on doing much Go dev you are going to want to setup a GOPATH eventually. Updating Godoc to a new version will need it. Any packages you might want for your dev work will be best installed into a GOPATH.

I would just bite the bullet and set one up.