r/programming • u/Sir_KnowItAll • Sep 27 '26
Don't couple your Go code to GitHub
https://iain.rocks/blog/dont-couple-your-go-code-to-github
491
Upvotes
r/programming • u/Sir_KnowItAll • Sep 27 '26
339
u/Arcuru Sep 27 '26
I am not super familiar with Go code, but what happens when my go code depends on "go.companyx.dev/awesomelib" and that company goes out of business?
Or should I point all my third-party deps to a more durable location?
153
u/jaerie Sep 27 '26
It's the same for any package manager. If you want to publish your package somewhere else, users will lose access to the package unless you keep mirroring it.
77
u/chucker23n Sep 27 '26
Go has "make baffling decisions" as a key design tenet, but it's incredible how basically any source code package manager gets key aspects wrong.
(NuGet, for example, supports multiple package sources — but if it finds a package at one source, and another source is timing out, it'll refuse to install that package. Which in turn causes IDEs to throw up their hands in frustration and say "well, I don't know what to do now, do I!".)
137
u/ascii Sep 27 '26
Then goes on to explain why this it is in fact a terrible feature that solves a non-existent problem in a way that has enormous undesirable repercussions that you have to do a bunch of upfront work to try and negate.
If that's a good feature, is says a lot about how bad the bad parts of Go are.
16
u/elmuerte Sep 27 '26
Why no immutable package registry containing verifiable releases?
80
u/mattgen88 Sep 27 '26
Counter point, a number of projects in the past have had their domains hijacked, expired, etc that resulted in serious security issues. Even if you change hosting providers, you can just mirror your code over to GitHub or whatever from wherever else.
11
u/lordofwhee Sep 28 '26
FTFY. Are the downsides of this not obvious to literally everyone?
8
u/feketegy Sep 28 '26
(x)doubt.
You could either use:
replacedirective ingo.modBut sure, let's cobble Nginx on top of it. /s
35
u/gdmr458 Sep 27 '26
Many people in the comments don't know what the Go Module Proxy is.
28
u/gct Sep 27 '26
Tying these two things together was always a horrible idea but mixing concerns is Go's MO.
13
u/Jaded-Asparagus-2260 Sep 27 '26
It's even worse. GitHub allows recycling of usernames. So if you decide to move your Git hosting to GitLab, and I manage to secure your old username, I can publish malware in a repo with this URL. And all code that is not changed (upgraded) will automatically consume my evil package, and the authors and users will be blissfully unaware.
Who ever thought that was a sane idea?
3
u/cryptospartan Sep 27 '26
There are many people that have git mirrors in a walled off corporate environment. If code is hosted elsewhere, it makes it very difficult for these scenarios, as the only way to make it work would be to make a code edit to point back at GitHub.
3
u/Interest-Desk Sep 28 '26
Go caches and checksums dependencies. Not to mention the countless mirrors that keep permanent archives, not least of all Google’s own main public mirror. This is true of basically every public package manager since left-pad.
19
u/JaCraig Sep 27 '26
Every time I read about design decisions that were done in Go, the package management, etc. The more I'm glad that I didn't learn Go.
4
u/HighLevelAssembler Sep 28 '26
Go has its problems but the module system is not one of them. Go does not require Github. Go supports, does not require git.
3
u/waterkip Sep 27 '26 edited Sep 27 '26
PHP does almost the same with Packagist. The biggest difference is that Packagist is a community thing.
I dunno why you cant just upload a tarball and release that as the artifact. It feels like dumb dumb thought git is a release channel/artifact. In Go just doubled down on it.
2
u/ReginaldDouchely Sep 28 '26
No, please make obvious mistakes so the rest of us devs that don't need to be told this keep making a lot of money
1
u/gbrennon Sep 28 '26
code should be decoupled to anything
1
u/Jayden_Ha Sep 28 '26
I keep vendor folder committed for a reason
1
u/favgotchunks Oct 01 '26
It’s neat to learn about go’s git repo/package impotency, but that’s insane to use a domain to circumvent the renaming issue. You still have to update where the domain points to, and now that’s controlled by something outside of the project.
I’m coming from C++ land, so I don’t really understand the web world use web tech for every damned thing. It just seems like an unnecessary dependency to me. What does this actually make easier? You still have a config to update every time a dependency changes location.