10 ms·
> The GOPATH environment variable now has a default value if it is unset. It defaults to $HOME/go on Unix and %USERPROFILE%/go on Windows. [0] Finally. This is
by nishs 10y ago
> The GOPATH environment variable now has a default value if it is unset. It defaults to $HOME/go on Unix and %USERPROFILE%/go on Windows. [0]
Finally. This is going to make it easier for newcomers to the Go ecosystem, since commands such as "go get" will now work out of the box.
[0] https://beta.golang.org/doc/go1.8#gopath https://beta.golang.org/doc/go1.8#gopath
- sofaofthedamned 10y agoBiggest thing on this release to be fair. Unbelievably simply but so effective, about time.
- voidlogic 10y agoWhat about the 5-10% performance boost? For me thats like getting a few hundred thousand dollars worth of free hardware...
- k2xl 10y agoEveryone I know who has learned Go has encountered this issue. "What's this GOPATH env variable? What should it be set to?" When I personally learned Go this (and how go do/doesn't do vendoring) was the hardest thing to learn. It's strange that it took this long to get this feature out. Now if they could figure out a way to get go get to work nicely with private repos out of the box without SSH config hacks that'd be great..
- deleted 10y ago[deleted]
- ashark 10y agoI like Go, but the GOPATH thing gave a very bad first impression.
- tedunangst 10y agoCurious why they didn't pick something like .go to be more out of the way.
- stouset 10y agoBecause it's supposed to be your actual development workspace. To be honest, I think this is one of the most asinine parts of the go development workflow (and there are a lot of contenders…). Having to organize all your go projects separately from everything else just because they happen to be developed in that particular language is maddening.
- fixermark 10y agoJava seems to have gone that road. Not sure if it was a bad idea or not.
- Psyonic 10y agoIn what way did Java go that road? Java doesn't impose any constraint on location across projects.
- StevePerkins 10y agoWhat are you talking about? It's simple to mix Java and C++ (or whatever) within the same project. Wellllllllll... until you actually start to write code against JNI, of course. But the project LAYOUT is simple!
- wtetzner 10y ago> Wellllllllll... until you actually start to write code against JNI, of course. JNA[1] makes things much simpler. [1] https://github.com/java-native-access/jna https://github.com/java-native-access/jna
- Manishearth 10y agoYeah, this gets super annoying when you need your project written in other languages to contain go code. I worked on the YCM support for godef, we eventually had to fork the library and rewrite paths since there was no way of pinning to a version within YCM. Libraries written with github paths for `go get` do not play nice with living outside of gopath, and libraries written with relative paths don't work with go get (even though this is something that go could support)
- echelon 10y agoWhy does Go require a special path for projects to be on? Python doesn't. Rust doesn't. This just seems annoying for no particular reason.
- majewsky 10y agoIndeed. I have a couple of Go projects that are released in the classical manner as tarballs, which users can extract anywhere and compile with `make && make install`. This used to work okay-ish until Go 1.5. Then Go 1.6 introduced vendoring support (i.e. you put the code for the libraries you need into your own repo) which is very nice if it works, so I wanted to have it. But `go build` stubbornly refuses to look at vendored code when you are not in the exact correct location inside the GOPATH. To preserve the familiar build semantics, I set up the GOPATH inside the repo. Roughly like this: $ git clone https://github.com/foo/bar && cd bar $ mkdir -p .gopath/src/github.com/foo $ ln -sTf ../../../.. .gopath/src/github.com/foo/bar $ GOPATH=$PWD/.gopath go build github.com/foo/bar Of course, all that bullshit can be nicely tugged away in the Makefile. For example: https://github.com/sapcc/swift-drive-autopilot/blob/a3d5d02ba86d59c6aa7aadbc9bfcef8b527bffa4/Makefile https://github.com/sapcc/swift-drive-autopilot/blob/a3d5d02b... You can find this either hilarious or sad. I like the irony in using make(1) to patch up the deficiencies of a tool that was created decades after it.
- ernsheong 10y agoThere is a tool called gb that helps you with this https://getgb.io/ https://getgb.io/ (I have no affiliation with gb)
- majewsky 10y agoWhile we're shamelessly plugging: I actually wrote my own vendoring tool after being confused by the ecosystem. It's a shell script of maybe 30 LOC: https://github.com/holocm/golangvend/blob/master/golangvend https://github.com/holocm/golangvend/blob/master/golangvend I hope to abandon it for an official solution, though, given that it appears and is good.
- 10y ago
- krakensden 10y agoArg, that's my GOROOT. For a while it was going to be ~/gocode, when did it get changed?
- amckinlay 10y agoAnd why not ~/Library/ for Mac?
- gjvc 10y agoThink I would have preferred $HOME/lib/go/ on UNIX ...
- fnord123 10y agoXDG doesn't have a XDG_LIB_HOME but I would guess it should be $HOME/.local/lib