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
View all comments
Show parent comment
5
u/Kraigius Sep 28 '26 edited Sep 28 '26
Afaik, in Go you can configure multiple package sources, it's just a bit different.
There's the
GOPROXYenvvar. Go always download from a proxy owned by google, then fallback to download the source code directly from github (or whichever source that you need).It's not configurable to specific packages but this is like configuring your global sources.
If your org have their own proxy then you can cache your deps and configure your
GOPROXYto prioritize it.You can use this to have your org scan and vet your deps.
Otherwise, for finer control you can add an instruction inside your
go.modfile to fetch yourdepAfrom gitlab instead of github, or anywhere else.In term of design, the syntax for this and the workflow kinda feel like an afterthought.
Golang download source code instead of a compiled artifact, so that's probably the consequence of that choice.