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.

Bb8ed71cd77d9da995685ca872b303e7?s=128

Nikhita Raghunath

February 24, 2017
Tweet

Transcript

  1. 3.

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

    compiler and standard library Mostly used for cross compiling purposes @TheNikhita
  2. 5.

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

    packages! Store dependencies fetched by go get! @TheNikhita
  3. 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
  4. 9.

    Some alternatives • Godep • Gb • Have separate gopaths

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

    Fin