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.
The Story of $GOPATH
Before GOPATH was born...
$GOROOT $GOOS $GOARCH
Used to find
Mostly used for
$GOPATH is born!
Some said nice things...
fetched by go get!
But others said...
What they complained
● Newbie adoption
● Phobic to freely located directories
● Only one copy of dependencies
● Can’t have vendored packages outside of
● Have separate gopaths for different projects
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!
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
4. Record the expected import prefix in a manifest file.
5. Infer the full import path from a git configuration.
6. With the official dependency tool, things might change!
Lots of suspense!!