Sunday 6 March 2016

Understanding GOPATH

During the process of writing the Bing Web API in Go, I learned a lot about how to use the GOPATH environment variable properly, and assembling all my projects in the same project path. Doing this makes all Go development easier. It actually took me a long time to accept that this was the best way to do it, but now I'm reorganising all my code to fit this pattern. 

For those who want to have a better understanding of GOPATH, have a look at the go environment variable and the go build package. It basically says

GOPATH=/home/user/gocode

/home/user/gocode/
    src/
        foo/
            bar/               (go code in package bar)
                x.go
            quux/              (go code in package main)
                y.go
    bin/
        quux                   (installed command)
    pkg/
        linux_amd64/
            foo/
                bar.a          (installed package object) 
In my case "foo/" is "github.com/borglefink/" and "bar/" is "bingapi/". All new projects hosted at my github.com account are added as siblings to "bar/" (like the suggested "quux/" above). Each of those "siblings" are connected to their own git repository. If I don't have my projects open-sourced, I can keep them on the "foo/" or the "bar/" level, whatever works for me.

If you don't quite "get" the structure, I really recommend looking at the documentation mentioned above.

1 comment:

  1. In current months, for example, minimal of|no much less than} three casinos in Peru have reported being cheated by Russian gamblers who performed aging Novomatic Coolfire slot machines. A highly unstable game has a low hit frequency as it requires bigger bets to win, and will provide larger rewards, however gamers run the chance of shedding huge as properly. On the opposite, much less unstable video games might have larger hit frequencies, however these typically provide smaller prizes for winners. Medium 온라인카지노 volatility video games can skew to both side based mostly on the prizing and is what allows the sport to have its “personality”. ●No Download Slots- This kind of online slots enable gamers to instantly leap right into the sport with out having to download and install the game’s software in their pc. It’s a fast, simple way to play, and players adore it for the comfort.

    ReplyDelete