HeadlinesBriefing favicon HeadlinesBriefing.com

Avoid GitHub Coupling in Go Code

Hacker News •
×

Go namespaces code by import location, often defaulting to GitHub URLs. This couples your code to the hosting provider, making migration to GitLab or Azure Devops difficult and costly. A company faced this issue while using all three platforms simultaneously, incurring extra fees due to the inability to switch.

The solution is to use custom domains like go.iain.rocks, go.uber.org, or go.mongodb.org. These act as stable prefixes; you only change where the domain points, not your code. For example, go.iain.rocks/boneclone redirects to github.com/thetrueares/boneclone.

The author provides Nginx and HTML configurations to implement this, allowing seamless provider changes without altering imports.