#27 Add macro for packages with `replace` in go.mod
Closed 3 years ago by proletarius101. Opened 3 years ago by proletarius101.

Although go-rpm-macros haven't support Go modules, which bascially means no lockfile & always using the latest deps available in Fedora's repo, it might be good to provide some macro to (imperfectly) handle some easy problems introduced by Go modules.

One of them is that when a module uses replace keyword to substitute module with another goipath (e.g. replace golang.org/x/crypto => github.com/ProtonMail/crypto in https://github.com/emersion/hydroxide/blob/master/go.mod). My proposal is to replace the golang.org/x/crypto with its real path github.com/ProtonMail/crypto. But any other ideas will be welcomed.


replace can not work in Fedora anyway because it is not transitive (it’s the kind of broken by design idea people invent when their primary target is to bundle piles of junk and avoid fixing their code).

source code that uses replace needs patching to use the real module/import name with or without modules. We have %patch and (soonish) patchlists for that, not sure a macro would be a lot more convenient, and it would certainly be more brittle.

Agreed that it looks messy. But in this case replace just means redirection and some name overlapping. Or maybe there should be some notes in Fedora's packaging guidelines to instruct the best practice to handle this?

rpm dependencies are transitive. That means replace can not be supported in rpm. That means the only sane way to handle replace is to remove it by patching code imports (which is not long or hard)

As to why non-transitive deps and 'to hell will everyone else, I only care about by own leaf node' approaches are a false good idea see the discussion on modules in devel right now. You win a little short term, you lose a lot long term as soon as the deferred technical debt catches up with you (as it caught up with the java module experiment).

Yeah. Not trying to really support replace but was asking how to deal with such case is acceptable and right for Fedora.
Now I know that just to replace the goipath to its real one by patches. Thanks for answering!

Metadata Update from @proletarius101:
- Issue status updated to: Closed (was: Open)

3 years ago

Login to comment on this ticket.

Metadata