Remix.run Logo
▲ dewey 9 hours ago

> That is, if you move your git hosting to GitLab then you have to change your code!

You can also just use "replace github.com/example/example => gitlab.com/example/example" in your go.mod file and everything will keep working. That seems like a very pre-mature optimization for something that doesn't really matter.

▲furyofantares 8 hours ago | parent | next [-]

Yeah, I think putting github.com in your repo is a mistake but it seems massively overstated. Seems trivial to fix all the code, or to just use go.mod, or first use go.mod and then fix your code.

▲kelnos 8 hours ago | parent | prev | next [-]

What about everyone else using your code? You are going to ask them all to update their code as well? Many of them probably won't realize, and will get stuck on an old version that never gets updated, even to fix bugs and security issues.

▲quacker 3 hours ago | parent | next [-]

I think the migration can be made pretty easy for users with deprecation notices and the `go fix` tool. Better explained in [1] (I have not tried it myself).

The idea is: the package maintainer pushes a final version of the old package that is a shim, and which has a deprecation notice. The shim imports the new package, and forwards all calls to the new package (and I suppose type aliases and variable aliases as well). The shim includes `//go:fix inline` annotations on all exported symbols, so that when users run `go fix` it rewrites their code to use the new package, by inlining their usages of the old package (which is now simply a shim that references the new package).

Not perfect. There is still a bit of a discoverability problem. Not all tooling warns on deprecated packages/functions (go toolchain doesn't, but gopls and staticcheck do). And users need to know to run `go fix`.

1: https://go.dev/blog/inliner#example-renaming-ioutilreadfile

▲jayd16 8 hours ago | parent | prev [-]

By this logic, those folks should be pointing to their own hosted mirrors of the project, no?

▲peesem 8 hours ago | parent | prev | next [-]

why not just use replacements to begin with if you don't want to bother with setting up domains?

"replace example => github.com/example/example" at first, then change to "replace example => gitlab.com/example/example" or similar when there's a migration

(i don't use go, but i hope this is possible and i am confused if it's not)

▲mort96 9 hours ago | parent | prev [-]

And you'll just leave references to abandoned infrastructure in your code forever?

▲cyberpunk 9 hours ago | parent [-]

cmd+shift+r in goland, push to a branch, open a PR, ask devops to make the old location archived and prevent further writes. After a couple months remove access to the old one and see what breaks.

You know, normal development task, small amount of story points..

▲mort96 9 hours ago | parent [-]

You're now arguing that it's easy, which is a completely different argument. The comment I responded to argued that it's unnecessary ("just do the rewrite in go.mod, leave source files unchanged").

For my thoughts about why it's not easy, see this comment: https://news.ycombinator.com/item?id=49870363

▲cyberpunk 9 hours ago | parent [-]

Yep that sounds pretty bad. Personally, we'd just eat not being able to build old versions, we archive previous builds, and in the case of a hotfix or whatever we'd use the go.mod rewrite trick. Not sure why you needed the commit/branch setup, did you change the history?

▲mort96 8 hours ago | parent [-]

Have libfoo with a bunch of different versions. Authservice depends on libfoo 1.2.0. APIservice depends on libfoo 1.3.0.

Now you want to move from github.com to git.example.org. You change libfoo, authservice and apiservice to use git.example.org, that part is just simple tedious work. But the v1.2.0 and v1.3.0 tags of libfoo are old commits from before the move, so they still reference github.com! Now you need to branch off of the v1.2.0 and v1.3.0 tags of libfoo and do the same change there.

So we have only 3 repositories with only 2 dependencies and we already have to do the search/replace 5 times.

Imagine now that apiservice depends on authservice v2.3.7 just to include some type definitions. Authservice is currently on version 2.4.0 but the types haven't changed so apiservice hasn't upgraded its dependency. Now you need to branch off of authservice v2.3.7 too and do the job there. Oh and authservice v2.3.7 depends on libfoo v1.2.5, so now you need to make a branch off of libfoo v1.2.5 with the search/replace.

3 repositories with a straightforward dependency relationship, 7 search/replace jobs.

The numbers get terrifying as you scale this up.