News for hackers. Stuff that matters.
Re:Go 1.8 Release Candidate 1 is released by stouset on Tuesday January 10, 2017 @05:20PM (#13369737)
Because 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.
Re:Go 1.8 Release Candidate 1 is released by Manishearth on Tuesday January 10, 2017 @05:27PM (#13369784)
Yeah, 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)

Re:Go 1.8 Release Candidate 1 is released by alexbecker on Tuesday January 10, 2017 @06:09PM (#13370124)
I use a make rule which appends the local go directories to GOPATH before running "go _". Inelegant, but it works.
Re:Go 1.8 Release Candidate 1 is released by jerf on Tuesday January 10, 2017 @10:31PM (#13371523)
I've got a couple of projects that contain Go code. The Go code does not need to be the top level of the project. I just either check it out into the gopath or symlink it in (usually the former since I've already set up CDPATH in bash to go to the directory the project is living in), and the import paths in my go code point at something like scm.localdomain.com/team/project/go, where the "project" directory is the top level directory for the project that has no Go code in it. This is even fully go getable if you "go get scm.localdomain.com/team/project/go/cmd/whatever" or something.
Re:Go 1.8 Release Candidate 1 is released by Manishearth on Tuesday January 10, 2017 @10:36PM (#13371550)
YCM can't require its users to do that, nor can it pollute the gopath which may not be set when it is installed, nor can it rely on that path always being the same or the installed files not being removed.

It's fine for a Go project, but this is not a Go project. It should not be forced to change how it works because it wants to contain some Go code.

Re:Go 1.8 Release Candidate 1 is released by mixedCase on Wednesday January 11, 2017 @12:03AM (#13371885)
>It should not be forced to change how it works because it wants to contain some Go code.

Go is not like Python, the end result is a binary, not interpreted source code. You can simply write a build script that sets a custom GOPATH inside a temporary folder, pulls all dependencies, builds and pops out a binary ready for use; and you can either discard or save your custom GOPATH anywhere for caching purposes.

Re:Go 1.8 Release Candidate 1 is released by Manishearth on Wednesday January 11, 2017 @12:08AM (#13371905)
Fair.

Note that this wasn't the only reason we had to fork. Go doesn't (or didn't) provide a way to pin to a dependency, so we would have had to fork anyway, and then rewrite all the paths anyway, so I went the way of using local paths in the fork.

Re:Go 1.8 Release Candidate 1 is released by mixedCase on Wednesday January 11, 2017 @01:09PM (#13376005)
You can probably consider unforking now that the vendor directory is a thing. I'm sure it'd be easier than rebasing on every update.
Re:Go 1.8 Release Candidate 1 is released by geoka9 on Tuesday January 10, 2017 @05:35PM (#13369852)
I actually like it. Makes it really easy to share code between my own programs - really handy for "microservice" projects. And if I want to have a Go program in a different source tree, links allow me to do that.
Re:Go 1.8 Release Candidate 1 is released by takeda on Tuesday January 10, 2017 @06:25PM (#13370256)
Go is opinionated how things are done, and just happens that its opinion fits yours, the issue is what when it doesn't?

With non-opinionated languages nothing is stopping you from structuring your code the same way.

Some people stated how hard go makes it when you try to have project that utilizes different languages. Another issue is when you try to use a fork of one of library.

Yet another is that it is much more complex to generate a package (e.g. rpm) of projects that has many dependencies.

Re:Go 1.8 Release Candidate 1 is released by geoka9 on Tuesday January 10, 2017 @09:46PM (#13371342)
> With non-opinionated languages nothing is stopping you from structuring your code the same way.

With Go, I can do `go build $project` from anywhere and get a releasable binary in the working directory. I can do `import "$oldproject/$package"` in my new project and start using it immediately. I can use `godef` to jump around all of the Go code installed on my system and quickly drill down all the way to the Go builtins if I need to. I can use `guru` to see all references to a definition across all of the Go packages installed on my system. The list goes on. And I can do all of that from a favorite text editor (and not a huge slow IDE). I never felt so liberated in any other programming environment, and I've used quite a few.

> Yet another is that it is much more complex to generate a package (e.g. rpm) of projects that has many dependencies.

Go binaries have only the standard system libraries for dependencies - for all practical purposes they can be considered static. Or you mean something else?

> Some people stated how hard go makes it when you try to have project that utilizes different languages.

I've used links successfully, but maybe my scenarios were not complex enough?

> Another issue is when you try to use a fork of one of library.

Vendor support since 1.6 made this a nonissue; it's now trivial to use forked versions of libraries.

Re:Go 1.8 Release Candidate 1 is released by Merovius on Wednesday January 11, 2017 @12:09PM (#13375464)
> Another issue is when you try to use a fork of one of library.

A fork of a library is either identical to the original, or a new library. And you could argue (or rather: I do), that it is a good thing that you need to explicitly specify which one you intend to use.

Re:Go 1.8 Release Candidate 1 is released by takeda on Friday January 13, 2017 @01:09PM (#13393005)
So let say you use code with many dependencies, but you want to make a small change in one of the dependencies. In other languages you would then just compile and be done with it, but now with golang you now need to also modify potentially hundreds of places unless you resort to somehow cheat golang.

As I said, being opinionated is great if the opinion matches yours otherwise you might end up fighting it on every step.

Re:Go 1.8 Release Candidate 1 is released by alexbecker on Tuesday January 10, 2017 @06:12PM (#13370152)
But how do you distribute such a project? Do you need an install script with any OSS project that includes go code, which sets up a bunch of links in the user's GOPATH directory? I imagine this script would be bug-prone and difficult for most users to debug.
Re:Go 1.8 Release Candidate 1 is released by regecks on Tuesday January 10, 2017 @06:54PM (#13370483)
I distribute commercial Go source with a Dockerfile to build the app (and rpm package) and it has been received remarkably well - better than I had imagined. YMMV.
Re:Go 1.8 Release Candidate 1 is released by geoka9 on Tuesday January 10, 2017 @10:06PM (#13371421)
I've only used Go for SaaS backends but if I wanted to distribute the code to 3rd parties I'd probably use a Dockerfile too.
Re:Go 1.8 Release Candidate 1 is released by gluczywo on Tuesday January 10, 2017 @06:09PM (#13370122)
You can view GOPATH centered development as a sign of simplicity. Probably not the most elegant thing in the world but the code organization is easy to fix with:

ln -s PROJECT_SOURCE_FOLDER $GOPATH/src/

Re:Go 1.8 Release Candidate 1 is released by majewsky on Tuesday January 10, 2017 @06:31PM (#13370289)
I actually adopted the GOPATH structure for all my repos, with some shell-script tooling (e.g. `cg github.com/foo/bar` is equivalent to `cd $GOPATH/src/github.com/foo/bar`, but clones the repo on first use). While transitioning to it, I indeed found quite a few repos that were checked out multiple times below my $HOME because of inconsistent directory structures.
Re:Go 1.8 Release Candidate 1 is released by derimagia on Tuesday January 10, 2017 @07:18PM (#13370616)
I use https://github.com/motemen/ghq for that, which is really nice actually.
Re:Go 1.8 Release Candidate 1 is released by Merovius on Wednesday January 11, 2017 @11:58AM (#13375359)
FWIW: I instead started organizing my workspace in the GOPATH layout (that is, I have GOPATH=~ and put a C project cloned from github.com/foo/bar at ~/src/github.com/foo/bar too). It also helps knowing where $random_repo was cloned from. YMMV
Re:Go 1.8 Release Candidate 1 is released by acln on Tuesday January 10, 2017 @09:33PM (#13371281)
I use GOPATH=$HOME. All the code (Go and other languages) lives under $HOME/src.
Re:Go 1.8 Release Candidate 1 is released by bluejekyll on Tuesday January 10, 2017 @09:52PM (#13371364)
And what about .git? And roots compatible with what other Devs expect?
Re:Go 1.8 Release Candidate 1 is released by Merovius on Wednesday January 11, 2017 @12:12PM (#13375497)
I don't see any problems with .git. Most go packages use git anyway, it would be pretty amazing if go tooling would break if you have a .git directory anywhere.

Re the other question: If you don't run a go command with a path name, it doesn't matter what the directory structure is. I have tons of non-go projects in my GOPATH and build them with the usual tools. No issues.

Re:Go 1.8 Release Candidate 1 is released by nishs on Wednesday January 11, 2017 @03:32PM (#13377258)
Running

  GOPATH=$HOME go get github.com/foo/bar
would download the package to:

  $HOME/src/github.com/foo/bar
So $HOME will not have .git.
Re:Go 1.8 Release Candidate 1 is released by 4ad on Wednesday January 11, 2017 @06:41AM (#13373242)
What about git?
Re:Go 1.8 Release Candidate 1 is released by bluejekyll on Wednesday January 11, 2017 @10:34AM (#13374615)
I was curious about how this recommendation effects other Devs and the .git and other similar paths in the Dev workflow.

That is, is the root of each go project effected?

Re:Go 1.8 Release Candidate 1 is released by 4ad on Friday January 13, 2017 @06:17AM (#13389965)
Sorry, I don't understand the question.

I also set GOPATH=$HOME, and all my source code (not only Go) lives in $HOME/src, and I do use git for both Go and non-Go projects (so they have a .git directory in $HOME/src/what/ever/.git), and there's no problem. Why would there be one?

Re:Go 1.8 Release Candidate 1 is released by fixermark on Tuesday January 10, 2017 @05:24PM (#13369768)
Java seems to have gone that road. Not sure if it was a bad idea or not.
Re:Go 1.8 Release Candidate 1 is released by Psyonic on Tuesday January 10, 2017 @05:36PM (#13369855)
In what way did Java go that road? Java doesn't impose any constraint on location across projects.
Re:Go 1.8 Release Candidate 1 is released by StevePerkins on Tuesday January 10, 2017 @05:51PM (#13369975)
What 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!

Re:Go 1.8 Release Candidate 1 is released by wtetzner on Tuesday January 10, 2017 @07:32PM (#13370706)
> 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