Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Story Of $GOPATH

The Story Of $GOPATH

Presented as a lightning talk at GopherConIndia 2017.

New programmers are often frustrated when they encounter $GOPATH while setting up their development environment. $GOPATH also establishes constraints over dependency management.

I talked about how GOPATH came along and what were people's reactions on it. I also talked about some of the proposals that have been in discussion to tackle this problem.


Nikhita Raghunath

February 24, 2017


  1. @TheNikhita The Story of $GOPATH

  2. Nikhita Raghunath Twitter: @TheNikhita Github: nikinath Website: https://nikinath.github.io/ @TheNikhita

  3. Before GOPATH was born... $GOROOT $GOOS $GOARCH Used to find

    compiler and standard library Mostly used for cross compiling purposes @TheNikhita
  4. $GOPATH is born! @TheNikhita

  5. Some said nice things... Easy to compute import paths of

    packages! Store dependencies fetched by go get! @TheNikhita
  6. @TheNikhita

  7. But others said... WHAT THE HELL IS IT?!!! @TheNikhita

  8. What they complained • Newbie adoption • Phobic to freely

    located directories • Only one copy of dependencies • Can’t have vendored packages outside of $GOPATH @TheNikhita
  9. Some alternatives • Godep • Gb • Have separate gopaths

    for different projects • HelloGopher @TheNikhita
  10. Current state of $GOPATH Go 1.8 release means a default

    $GOPATH! Yay!! • $HOME/go on Unix • %USERPROFILE%\go on Windows If you want, you can also set it to whatever you like! Thanks to Francesc Campoy for this! @TheNikhita
  11. Future - RIP? 1. Drop pkg in favor of a

    hidden cache directory. 2. Use the ./vendor directory as $GOPATH/src. Go get automatically downloads packages to ./vendor. 3. When walking up the filesystem to the root, whenever /foo/bar/src is found, /foo/bar is prepended as a $GOPATH. @TheNikhita
  12. Future? 4. Record the expected import prefix in a manifest

    file. (Kang) 5. Infer the full import path from a git configuration. (Kodos) 6. With the official dependency tool, things might change! Lots of suspense!! @TheNikhita
  13. Fin