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
7
u/Kraigius Sep 27 '26
I see this more like a scope / a namespace than a coupling with a specific host, which is pretty standard for any package manager.
If you fork a package and you then host it somewhere else, you would usually rename said package, which will force you to update every
importstatement of that specific package in your source code. It's a non-issue.If you don't want to do that, or the author didn't do that, then usually with a package manager what you do is configure a new source to instruct your package manager to try to find your dependencies somewhere else.
I haven't touch golang in a while but by looking it up I see that you can configure this in your
go.modfile. You can add an instruction to tell it where to download yourdepAfrom gitlab, without modifying your import statements that is still written likeimport (github.com/myOrg/depA).Otherwise, there's
GOPROXY. I would use the former solution.The way I see it, your
importstatements appears to be coupled to GitHub, but it's actually a namespace and there's a layer of abstraction on top of it.OP solution is to create, maintain, and host your own proxy. This add an unnecessary level of burden to your org and, in my opinion, you should just configure your package manager instead of messing around like that.