Tuesday, May 9, 2017

GOPATH and Go Environment Variables

I was a bit confused by The Internet's many comments on Go environment variables.  Here's my simple-minded take.

Go Environment Variables
  • go env will show you all the environment variables Go cares about and what Go believes them to be set to.
  • You can ignore most of them, they have details 
Basic GOPATH
  • Default GOPATH is $HOME/go.
  • If you're fine with this default, you don't need to set this.
  • I set it anyways, just for fun

Don't Set GOROOT or GOROOT_BOOTSTRAP

GOROOT is used to handle non-standard installations.  GOROOT_BOOTSTRAP is used when compiling Go from source.  In a future post I'll cover using these when building Go from source.

Using Multiple GOPATHs

When you're first starting out, plan on keeping your various projects together under $HOME/go.

Later, you may want to have multiple GOPATHs:

  • You might be working for different clients, and not run the risk of mingling their code or dependencies.
  • You might have particular revision control needs; for example, a larger project may have a subproject written in go.
I don't quite grok Go's project/subdirectory mapping at this time.  I'm studying it now and I'll write about it in the very near future.


blogodex = {"toc" : "GOPATH", "idx" : ["environment variables"]};

Thursday, May 4, 2017

Contributing Go Examples

How to write Go examples:
Use this guide to get started:
Notes if you're going through contribute.html for the first time:
  • If you have a specific review, use "git mail -r review...".  If you follow the document strictly, you will mail off the submission before it mentions this step.
  • The first time you build the entire go tree, you need to specify a GOROOT_BOOTSTRAP.  Details in How To Write Go Code, tl;dr for standard Mac install is: GOROOT_BOOTSTRAP=/usr/local/go ./all.bash
blogodex = {"idx" : "writing examples"};