The GOPATH is for everyone

Tyler Finethy
The Startup
Published in
3 min readOct 17, 2019

--

The Go tool-chain can be useful even outside of Go development

TL;DR

The command go get will organize your code into an easy to follow directory structure that you can use across all your work-spaces. Give it a try even if you’re not a gopher.

Example: go get github.com/golang/go will clone the repository and put it at $GOPATH/go/github.com/golang/go where GOPATH usually defaults to your home directory.

Background

When I started using Golang 3 years ago, I came from a world of Python, PHP, and NodeJS where every time I created a new repository I would have to think about where it was going to go. This would usually result in directory structures like:

.
├── repo1
├── myCode
│ ├── repo2
│ ├── repo3
│ └── repo4
├── myOrg
│ ├── repo5
│ ├── repo6
│ └── repo7
├── opensourceOrg
│ ├── repo10
│ ├── repo8
│ └── repo9
└── scratch
├── repo11
├── repo12
└── repo13

Maybe I’m not disciplined enough, but this tree could look wildly different depending on my mood, the amount of coffee I’ve had, or what task I’m thinking about and working on.

There’s actually information lost here:

  • What organization/user does repo1 belong to?
  • Are we sure that every repository in myCode is ours?
  • What version control system do…

--

--

Tyler Finethy
The Startup

Software Engineer at RStudio, with a passion for small companies with big challenges. Currently interested in Golang and tech leadership @tylfin 🚀