News for hackers. Stuff that matters.
Re:Go's old $GOPATH story for development and dependencies by stairlane on Thursday May 23, 2024 @09:49AM (#40454701)
I struggle to see the authors point.

His last sentence:

> It could have worked, at least in theory, in a world where preserving API compatibility (in a broad sense) is much more common than it clearly is (or isn't) in this one.

Is he implying that using vendor packages is more clear that using version tags in a go.mod? That would certainly be the first I’ve ever heard of someone preferring dependency management via vendor packages over a go.mod & ‘go get’.

Personally I absolutely love the way go manages dependencies. I have way more confidence that my old go programs will run with minimal dependency related issues compared to programs written in something like python.

Re:Go's old $GOPATH story for development and dependencies by mdaniel on Thursday May 23, 2024 @11:54PM (#40462640)
There is a small asterisk about "more clear" in that if one vendors the deps, they are guaranteed to be available, and not subject to github outages, which seems to be 99.5% of all go deps in the world

It for sure is easier to reason about a declarative text file than 18 quadrillion .go files in a subdirectory, but using go.mod does come with tradeoffs

Re:Go's old $GOPATH story for development and dependencies by Yasuraka on Friday May 24, 2024 @05:54AM (#40464556)
Go uses $GOPROXY which points to https://proxy.golang.org/ by default with direct sources as fallback, very reliable
Re:Go's old $GOPATH story for development and dependencies by siebenmann on Friday May 24, 2024 @12:01AM (#40462682)
My badly communicated overall point is that I don't think it's right to say that Go started without any thought about dependency management. Instead, the Go developers had a theory for how it would work (with $GOPATH creating workspaces), but in practice their theory didn't work out (for various reasons). For me, this makes the evolution of Go modules much more interesting, because we can get a window into what didn't work.

(I'm the author of the linked-to entry. I wrote the entry because my impression is that a lot of modern Go programmers don't have this view of pre-module Go, and especially Go when you had to set $GOPATH and it was expected that you'd change it, instead of a default $HOME/go that you used almost all the time.)

Re:Go's old $GOPATH story for development and dependencies by quectophoton on Friday May 24, 2024 @04:07AM (#40464045)
> but in practice their theory didn't work out (for various reasons)

For me, one of the reasons I disliked $GOPATH is that source code was not in $GOPATH; it was in `$GOPATH/src`.

The fact that they are very strongly against relative imports also didn't help, even if I get why they do it.

Re:Go's old $GOPATH story for development and dependencies by demi56 on Friday May 24, 2024 @04:41AM (#40464214)
From my experience the reason $GOPATH has pkg, bin src directory was they wanted to limit spread of affecting the filesystem, I could zip my go directory put it in another computer and still works as good as before, I hated Python because it couldn’t do this even pyenv have high chances of it not working correctly if changed to a different distro and most times I don’t wanna download 500M of anaconda everytime I swap.
Re:Go's old $GOPATH story for development and dependencies by gwd on Friday May 24, 2024 @04:32AM (#40464171)
It's certainly an interesting angle. It might have been more clear if the documentation and how-to's had explicitly used that sort of terminology: e.g., saying that step 1 of creating a project would be to create a new workspace directory for all the dependencies, then create a package directory (with a git tree) inside that.

There are certainly nice things that the current Go module system buys; but one thing I miss is that under the old system, if one of the packages wasn't working the way you expected, the code was right there already; all you had to do was to go to that directory and start editing it, because it was already cloned and ready to go. The current thing where you have to clone the repo locally, add a "go.work" to replace just that package locally to do experimentation, and then remove the "go.work" afterwards isn't terrible, but it's just that extra bit of annoying busy-work.

But being able to downgrade by simply changing the version in go.mod is certainly a big improvement, as is having the hashes to make supply chain attacks more difficult.

Re:Go's old $GOPATH story for development and dependencies by peter_l_downs on Friday May 24, 2024 @09:05AM (#40465809)
You can directly edit the downloaded code when using modules, you don’t need your go.work flow at all. I often do it while debugging particularly weird bugs or to better understand library code I’m using.
Re:Go's old $GOPATH story for development and dependencies by gwd on Friday May 24, 2024 @11:56AM (#40467443)
One way or another, the current workflow has to be:

1. Download the code (or update the copy you downloaded last time you had an issue)

2. Redirect `go build` to use the downloaded copy rather than the upstream copy (either by modifying go.mod or go.work)

3. Do the editing

4. Undo #2

Under the old system, you just had to do #3. And sure, it's not that much work, but it's a bit more than I had to do before.

Re:Go's old $GOPATH story for development and dependencies by peter_l_downs on Tuesday May 28, 2024 @10:23AM (#40501023)
You can just edit the copy that ‘go get / go build’ download to your system. Afterwards undo the edits or re-download the module to wipe out your edits. No need to use go.work, local replaces, or anything. The files are on your disk!
Re:Go's old $GOPATH story for development and dependencies by metaltyphoon on Friday May 24, 2024 @11:06AM (#40466978)
Its much better to do go.work and add to your ignore. This way you won’t have to muck with go.mod and commit the file with local replaces
Re:Go's old $GOPATH story for development and dependencies by dfawcus on Friday May 24, 2024 @06:56AM (#40464852)
> Is he implying that using vendor packages is more clear that using version tags in a go.mod? That would certainly be the first I’ve ever heard of someone preferring dependency management via vendor packages over a go.mod & ‘go get’.

Isn't it the case that Debian builds of go 'packages' (i.e. making a .deb package') are using the pre modules mechanisms? If so, then they would seem to prefer it for some reason.

Re:Go's old $GOPATH story for development and dependencies by guilherme-puida on Friday May 24, 2024 @07:54AM (#40465217)
> Isn't it the case that Debian builds of go 'packages' (i.e. making a .deb package') are using the pre modules mechanisms?

As far as I know, yes: https://salsa.debian.org/go-team/packages/dh-golang/-/blob/d...

Re:Go's old $GOPATH story for development and dependencies by vetrom on Friday May 24, 2024 @10:23AM (#40466580)
They prefer it for a number of reasons, for better or worse.

The big reasons I usually call out are:

- packages should be buildable without calling out to any network resources. (this is the primary reason Debian dh-make-golang disables 1.11 style gomod support)

- Debian specifically avoids vendored copies of code. This does create functionality and miantenance challenges, but it also produces a leaner installed code base. One again, for better or worse, this is a standing part of Debian package policy and warts from this particular choice stand out all over, not just golang. (newer Debian python, for example outright disables pip for non-venv python)

There are other nits and warts that become apparent, but I think those all waterfall out from the two points I've called out here.

(The Debian package policy in question: https://www.debian.org/doc/debian-policy/ch-source.html#embe...)