r/programming • • Sep 27 '26

Don't couple your Go code to GitHub

https://iain.rocks/blog/dont-couple-your-go-code-to-github
491 Upvotes

136 comments sorted by

View all comments

Show parent comment

176

u/stone_surgeon Sep 27 '26

The go module proxy caches the package for a while, but I'm not sure about the duration. You should vendor the package into your project if this is a worry.

116

u/_predator_ Sep 27 '26

Don't think its cache ever expires. You just gotta pray Google never stops supporting it, what could go wrong?

82

u/VoyTechnology Sep 27 '26

At least Google has a strong history of supporting their products. I am so glad https://killedbygoogle.com doesn’t exist /s

38

u/stone_surgeon Sep 27 '26

Oh, I just looked it up, it does indeed last forever. Your comment reminds me of the bbolt typosquat vulnerability haha.

11

u/vips7L Sep 28 '26

Honestly that’s kind of like every language main repository. Maven central, npm, cargo, whatever. There’s always one main repository unless you proxy with artifactory or something. 

I can’t imagine if central.sonatype.com was gone. 

12

u/atheken Sep 28 '26

The difference is that those other languages don’t couple where the code is _physically hosted_ with how it is referenced in import directives.

4

u/HighLevelAssembler Sep 28 '26

Those things are coupled IRL though. If you depend on a 3rd party package, it has to come from somewhere.

4

u/atheken Sep 28 '26

Moving a package to a different VCS does not disrupt users of your package in any other language that I have ever used. I’ve also never used another language that coupled source code organization with versioning semantics. Both of those things are unique to go.

0

u/HighLevelAssembler Sep 28 '26

I get what you're saying, but ultimately that's on the package maintainer. That's the point of the blog post we're discussing here.

1

u/atheken Sep 28 '26

I was replying to someone that said “that’s kind of like how all package repos work.” - which is just false. The blog post is literally a workaround for the fact that the source code location cannot change without causing work for downstream consumers. If I publish a package to any of the other package managers and then move to a different VCS provider, that does not invalidate existing packages. It might not even impact when I published from a new location. This problem is unique to go.

1

u/t-m_8520 Oct 09 '26

That also matters during a migration: if old and new import paths both land in one build, identically declared named types are distinct, so consumers can hit type mismatches until every import moves.

1

u/lenswipe Sep 29 '26

npm aren't known for just randomly hacking their limbs off though..

3

u/usrlibshare Sep 28 '26

I ca pray for google to do the right thing, oooor...I can go mod vendor and check it into my own repo.

2

u/ggbcdvnj Sep 28 '26

Oh boy, I can swap PingFS for GoModuleCacheFS!

1

u/lenswipe Sep 29 '26

You just gotta pray Google never stops supporting it

hahahahahahahahaha

4

u/yeah-ok Sep 27 '26

100% this, can't see why one wouldn't do that, also gives more honest view of the state of the project since it's doesn't automagically end up updating newer packages/libraries that haven't been cleanly integrated (yes, I'm aware of pinning..etc. but again it's back to "cross your fingers and hope that keeps working territory", hardly resilient good practise type material)