-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: setting up a multi-module single repo is difficult #27056
Comments
A go.mod is like its own little GOPATH. There is no implicit reference to other nearby modules. In particular being in one repo does not mean that they all move in lock step and always refer to the code from the same commit. That's not what users will get either. If there is an inter-dependency, you need to add it, with something like
|
This issue is closely related to #26241, #25053 and other issues that involving development of multiple modules concurrently and access to local modules. In the above example, one caveat is that the 'replace' rule doesn't take effect until there exist the 'require' entry for the replaced module. That's why I ended up using 'go mod edit -require' which is not meant for use by human. (#27060) So, in order to add the local inter-dependency, users need to either
At the beginning of converting an existing repo to a multi-module repo, currently, users will need hand-edit go.mod file (go mod edit -require and go mod edit -replace) and careful planning of commit ordering. |
@rogpeppe's |
@hyangah I submitted an experience report for a similar setup. From my perspective, the only "problem" is the requirement on existence of the submodule (and I don't think we can solve that problem). For me, this was step 1. But this was only a "problem" in so far as my CI build broke. Beyond that commit, all was fine.
This is effectively the crux of my open questions too. I'm less worried about the "hand-edit" part, because I think tooling can easily fix that. It's the commit dance that follows that raises the biggest question. Again, tooling could help, but because of the mix of VCS systems that people may be using, it's not immediately obvious. With Gerrit things are certainly much easier... |
As an experience report, our Go code at Square is organized in a similar fashion. We are still using We have O(dozens) of apps at It doesn't seem as if hosting multiple modules out of a single repo is clean (version tags are per-repo), but we're considering giving each app a separate We're also considering some kind of linter/auto-go.mod-writing tool to ensure that all Anyway, just wanted to log a report. I expect within Google, Go code is still built using blaze, with custom tooling, so I don't expect monorepo experience help from inside :-) |
@zellyn just to check on one point:
Do you mean your version tags are per-repo? Because in general multi-module versions work as a result of the submodule prefix on a tag. For example the repo that results from the submodules (multi-module repo) guide has the following two tags (i.e. versions):
This would presumably be a wrapper around |
Ah, I somehow missed that you could namespace version labels like that. Simple and clear. Thanks!
I imagine so, probably. The more important reason for linting is that we need to catch an app accidentally not using our protobuf fork. It could result in not redacting sensitive fields in logs, for example. |
That seems like a problem you could resolve with a |
Interesting idea. I'll have to see if we can get our Artifactory instance to do that, after we get the basic functionality working). |
We've addressed a number of the underlying issues, although there are certainly still some difficulties in setting up and testing multi-module repos. Let's track the remaining issues individually rather than under this umbrella issue. I know that at least the following are related: |
Let's say we have a repository containing three packages and
we decided to organize them in separate modules for some reasons.
The purple package imports blue and red packages.
We created go.mod files in each package directory using 'go mod init example.com/purple/red', etc.
Now we try to build the purple package.
What's happening underneath is, the
go build
command querieshttps://example.com/purple/red?go-get=1
, ... to get the meta tags. That means, until I check in the packages and go.mod files to the remote repository and make them accessible, I can't build/test.What's the easiest way to start a multi-module repo with inter-dependency?
The text was updated successfully, but these errors were encountered: