$30 off During Our Annual Pro Sale. View Details »

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. @TheNikhita
    The Story of $GOPATH

    View Slide

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

    View Slide

  3. Before GOPATH was born...
    $GOROOT $GOOS $GOARCH
    Used to find
    compiler and
    standard library
    Mostly used for
    cross compiling
    purposes
    @TheNikhita

    View Slide

  4. $GOPATH is born!
    @TheNikhita

    View Slide

  5. Some said nice things...
    Easy to
    compute import
    paths of
    packages!
    Store
    dependencies
    fetched by go get!
    @TheNikhita

    View Slide

  6. @TheNikhita

    View Slide

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

    View Slide

  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

    View Slide

  9. Some alternatives
    ● Godep
    ● Gb
    ● Have separate gopaths for different projects
    ● HelloGopher
    @TheNikhita

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  13. Fin

    View Slide