You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
I propose that we add a new optional -maxdepth <uint> flag to go work use -r moddirs. It limits the level of directories to descend into for each moddirs, like how the -maxdepth in the Unix find command works.
The text was updated successfully, but these errors were encountered:
most go modules are defined at the root directory of repos, and most people have go projects cloned onto their local filesystem either in one directory (flat layout) or in a hierarchy of sub-directories with a known/limited depth. So a -maxdepth flag can be used to limit the search scope in these cases and prevent bogus or unwanted go.mod files from becoming accidentally included in the work space (e.g. issue #51959) at which point users would then have to prune those out, which is cumbersome.
Depth seems like a poor proxy for the actual issues, a multi module repository can easily have modules at different depths, while a checked out dependency in the same workspace (eg, x/tools from the other issue) may have "unwanted" go.mods at the same depths.
I don't see this as a generally useful mechanism for excluding unwanted module declarations.
-maxdepth is only useful for cases where the desirable depth of directory for where to find go modules to be included in the work space is known. I suspect this is the common case.
Even for cases where a directory level contains both desirable go modules and undesirable ones, limiting the search scope with a max depth would result in fewer (or equal) undesirable ones that need to be pruned out than that of allowing the search scope to be unbound.
ianlancetaylor
changed the title
proposal: add -maxdepth to go work use -r
proposal: cmd/go: add -maxdepth to go work use -rApr 17, 2022
I propose that we add a new optional
-maxdepth <uint>
flag togo work use -r moddirs
. It limits the level of directories to descend into for eachmoddirs
, like how the-maxdepth
in the Unixfind
command works.The text was updated successfully, but these errors were encountered: