Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: option to initialize go mod from git submodules #47824

Closed
mcandre opened this issue Aug 19, 2021 · 3 comments
Closed

cmd/go: option to initialize go mod from git submodules #47824

mcandre opened this issue Aug 19, 2021 · 3 comments
Labels
FeatureRequest GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mcandre
Copy link

mcandre commented Aug 19, 2021

Hi,

I have historically used git submodules as the most reliable way to manage library dependencies in my Go projects. I would very much like to migrate to modern Go modules. However, the go mod init system does not appear to support generating go.mod configurations from git submodules.

When I try to do this, I either get NO modules in the resulting go.mod file, or else I get the latest versions of everything, which of course breaks my application. Please include automation for migrating vendor/ directories from git submodules to go.mod.

Furthermore, when I try to explicitly copy the exact same git refs for the dependency versions, then go mod operations corrupt these. go mod checks out a completely different version of the dependency tree than I have in the original vendor/ with git submodules.

If someone can help me to reliably migrate the exact same dependency tree to go mod, then I would be grateful.

Example:

https://github.com/mcandre/octane/tree/61e9374d9695f2b3f1489741396f4f3082f3fd74

@mknyszek mknyszek changed the title Option to initialize go mod from git submodules cmd/go: option to initialize go mod from git submodules Aug 19, 2021
@mknyszek mknyszek added FeatureRequest GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 19, 2021
@mknyszek mknyszek added this to the Backlog milestone Aug 19, 2021
@mknyszek
Copy link
Contributor

CC @bcmills @matloob @jayconrod

@jayconrod
Copy link
Contributor

Could you say more about how you're using submodules? Concepts in Go modules and Git submodules don't map directly to each other, so it's not clear to me how this would work or whether it would be feasible.

It sounds like you have submodules checked out into the vendor directory, presumably at locations that correspond to repository root paths. If that's the case, then git submodule status would show something like this for each repo:

012345abcdef vendor/example.com/repo

It's probably feasible for go mod init to list directories inside vendor containing .go files, find what submodule they belong to, then build a go.mod based on that. Does that sound about right?

We're probably not going to be able to get to this soon; I don't think many people are in this situation. In the mean time, you can simulate the result by using go get to pull in each dependency.

go get -d example.com/repo@012345abcdef

@jayconrod jayconrod modified the milestones: Backlog, Unplanned Aug 20, 2021
@mvdan
Copy link
Member

mvdan commented Apr 9, 2023

Could you say more about how you're using submodules? Concepts in Go modules and Git submodules don't map directly to each other, so it's not clear to me how this would work or whether it would be feasible.

This never got a response, and it seems like noone else needs this or cares to implement it, so I'm going to close this feature request for now.

@mvdan mvdan closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants