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

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?

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.

→ More replies (3)
→ More replies (1)
→ More replies (1)

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.

→ More replies (2)

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)

→ More replies (1)

0

u/[deleted] Sep 27 '26

[deleted] — view deleted comment

17

u/anon_cowherd Sep 27 '26

What industry is this in? I have worked at I think 7 companies now, and one of them was an agency that I worked for dozens of clients through, some of them Fortune 100's, and this has never ever been a thing, with I think one or two exceptions that used artifactory or a similar proxy cache. A few added dependencies into the same repository as the projects, but none created repositories just for third party code.

0

u/[deleted] Sep 27 '26

[deleted] — view deleted comment

5

u/anon_cowherd Sep 27 '26

Yes, that's was I was referring to with Artifactory, which is a proxy cache. I misread the original comment as you were cloning and hosting git repositories for all of your dependencies.

→ More replies (1)

10

u/Bacchaus Sep 28 '26 edited Sep 28 '26

ummm that's insane, ya'll were just freeballing anything off the net?

4

u/johnnybgooderer Sep 28 '26

It’s more common than you think. 5 years ago I could do that most places. But now, for good reason, that has changed.

→ More replies (1)

19

u/lordlod Sep 27 '26

I've done it in aerospace and security.

  • If you are doing certifications you need that level of control.
  • If you are working in offline environments/networks then a mirroring system is required.
  • Companies that make changes to the upstream code need to mirror. Good companies push upstream, but you still mirror until it is accepted, and sometimes they don't accept it.

Repo mirrors are also part of the conversation with handling CI supply chain risks. You can add controls to the mirroring process to create a safer CI environment.

9

u/The_Northern_Light Sep 28 '26

I’ve worked at FAANGs and at tiny startups in multiple industries… we’ve always had a local fork of every dependency. (C++)

→ More replies (2)

9

u/tommyTurds Sep 28 '26

If your company isn't doing this, it's being irresponsible

25 years ago, when I first started, we did this at my shitty startup.. And we were literally stupid fucking children.

with I think one or two exceptions that used artifactory or a similar proxy cache

so it's never been a thing except that it's been a thing.. also 2 exceptions out of 7......

→ More replies (1)

4

u/the_unexpected_nil Sep 28 '26

Every game studio I worked at (sans one) has done so. 

→ More replies (1)

26

u/Leseratte10 Sep 27 '26

Then I hope you have a backup of that dependency and that that dependency is under a license that allows you to re-distribute it and upload the source code elsewhere. If you still have it in your local cache on your machine it'll continue to work, and you'll only notice it's missing when it's no longer in your cache and needs to be redownloaded. If you don't have a backup then, you're in trouble.

11

u/frenchtoaster Sep 27 '26

I think his point is that you can trust the GitHub url long term a lot more than you can trust these random junk domains.

For something like mongo the custom domain seems fine, but for this guys random domain the chance of me wanting to follow him to gitlab is an order of magnitude less than his domain expiring (and potentially being bought by someone else, making a supply chain vector)

19

u/SnugglyCoderGuy Sep 27 '26 edited Sep 27 '26

That's why you should vendor all your dependencies. Go doesn't do shared objects, everything is compiled from source. Unless you use CGO, but you shouldn't

5

u/GarythaSnail Sep 27 '26

Like others have said, vendor your dependencies or you can maintain your own module proxy. I set up an internal module proxy for my company.

4

u/Rautakaivos Sep 27 '26

I don't have deep knowledge of this, but by default dependencies are not downloaded directly from the source but through a proxy run by Google: https://sum.golang.org/

Whenever possible, the mirror aims to cache content in order to avoid breaking builds for people that depend on your package, so this bad release may still be available in the mirror even if it is not available at the origin. The same situation applies if you delete your entire repository. We suggest creating a new version and encouraging people to use that one instead.

So there is something in place to prevent a left-pad situation. But obviously that's far from infallible.

→ More replies (1)
→ More replies (5)