published on in blog
tags: neuling go

Gotool

The old adage is “a poor craftsman blames his/her tools.” The golang tools should never suffer such defacements; they are simply sublime. However, even the fanciest (or for that matter simplest) hammer can mash a finger if used improperly.

In the next few posts, I’m going to do a shaleep1 dive into the go tool. If you’ve played with the go tool, you know a lot of functionality is baked in. If you haven’t played with the go tool very much, stay tuned! We’re about to undertake a whirlwind tour of the tools, but first a disclaimer:

Disclaimer

I am not claiming (nor desiring) to be the absolute truth on the go tool. Rather consider this collection of recollections one person’s journey down the rabbit hole. If I have something incorrect or misrepresented, please send me a message so I can address the problem(s). By doing so, in some small incremental way, you will have helped advanced the whole of humanity. Wouldn’t that feel nice?

go version

Right, so you’ve just installed go, and your anticipation is reminiscent of opening presents on Christmas morning. You just can’t wait to get out there and write your first micro platform distributed cloud as a service (or whatever it is kids these days are doing). But let’s pause for just a second and reflect. Open up your terminal, and type go version. My output is below, yours will likely vary from mine:

$ go version
go version go1.9.2 linux/amd64

Does this command work? Is it the version you expected? Once we’ve done something, it’s usually worth checking we actually did what we meant to do. (or done-did-do as I like to put it)

go env

The next command to look at is go env. It isn’t as flashy as some of the other go tools, but important nonetheless. It lets you know exactly how your go installation is configured. Again mine is below, yours will likely vary.

$ go env
GOARCH="amd64"
GOBIN="/home/harpercn/devel/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/harpercn/devel/go"
GORACE=""
GOROOT="/opt/go"
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0
-fdebug-prefix-map=/tmp/go-build737507707=/tmp/go-build
-gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

The most important bits here are the GOPATH and GOBIN. Depending on the version of go, and how/where it was installed, these values might need some tweaking. Check the official go doc for guidance. If you are still struggling, feel free to send me a message.

To be continued

That’s the end for now, but not the end of our story. I’ll put links here to the other parts of go tool as I write them.

go build first part

Happy Coding! C$


  1. Shaleep –> Not too shallow whilst not oppressively deep. But seriously, what do you call something that is neither shallow nor deep? [return]