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
Tweet

More Decks by Nikhita Raghunath

Other Decks in Programming

Transcript

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

    compiler and standard library Mostly used for cross compiling purposes @TheNikhita
  2. Some said nice things... Easy to compute import paths of

    packages! Store dependencies fetched by go get! @TheNikhita
  3. What they complained • Newbie adoption • Phobic to freely

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

    for different projects • HelloGopher @TheNikhita
  5. 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
  6. 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
  7. 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
  8. Fin