-
Notifications
You must be signed in to change notification settings - Fork 11
proposal: switch to using nested modules for -m mode resolution #81
Comments
In 6038506 we incorrectly optimised away an install step when -m is supplied. We must always install if we are in -m mode, because the main module is responsible for resolving versions. We therefore utilise the install step to effectively ensure the target binary is up to date. This logic would change if were to adopt #81 because we would then only install non-versioned module packages (i.e. non-main module, non-directory replaced), or in the case a versioned target does not exist in the gobin cache.
In 6038506 we incorrectly optimised away an install step when -m is supplied. We must always install if we are in -m mode, because the main module is responsible for resolving versions. We therefore utilise the install step to effectively ensure the target binary is up to date. This logic would change if were to adopt #81 because we would then only install non-versioned module packages (i.e. non-main module, non-directory replaced), or in the case a versioned target does not exist in the gobin cache.
Do we need one go.mod file per tool dependency? For example, I see no value in different tools using different versions of Going even further - why not add the go.mod/go.sum data right into go.tools? As a silly example, using txtar itself:
|
To clarify; my point about using a single However, one disadvantage is that not having the plain files on disk somewhere would make it harder to use vanilla
|
I would argue yes, and I suspect @rogpeppe would too. Various reasons:
Just to confirm, the "overhead" for modules requiring tools under this proposal would be:
Is your concern about the number of files in this |
Gotcha, thanks. I hadn't thought about the side effects as much as you two have. Not convinced that this is a clear decision, but I see it's a tradeoff.
My concern is the number of files in the root of a module. Right now we already have |
Agreed.
Indeed. |
note that you only need such a nested module for tools that don't contain a go.mod file. Hopefully that will become increasingly uncommon as time goes on. |
There are two reasons why I think we should still have a
|
If we live in a world where
Are you positive about this? I understand why a |
I don't think so. Assume either the main module or a (transitive) dependency has incomplete dependencies. At time
But the |
Building on the ideas started in #44.
Currently, the
-m
flag tellsgobin
to use the main module for resolution of dependencies.-m
can also, therefore, be thought of as "non-global" mode. In-m
mode, we use the guidance at golang/go#25922 (comment) for keeping track of the tools we require in a build-ignoredtools.go
file.Under this behaviour however,
-m
mode ends up cluttering our main module.#44 proposed an alternative means of capturing the list of tools we require in a
go.tools
file. This issue more precisely specifies the behaviour as follows:go.tools
will capture the import paths of tools we require, e.g.:gobin
will then use synthetic nested modules (in a.gobin
directory) per main package for module resolution (including the main package's module). For example:Points to note:
cmd/go
module cachereplace
directives in the main package's main module will appear in the synthetic nested module for a main packagecc @rogpeppe @mvdan
The text was updated successfully, but these errors were encountered: