-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
For a number of use-cases, it would be helpful to be able to upload modules to the module cache from source code (not just zip files!) in a local directory or repository.
Some examples:
- Testing changes involving cyclic module requirements (cmd/go: support simultaneous edits of interdependent modules #27542, cmd/go: ensure that 'go mod tidy' and
go get -udo not introduce ambiguous imports #27899). - Bootstrapping a server to serve the module containing itself (cmd/go: mod vendor should work offline #28029, but that can be worked around using
replacedirectives). - Storing and distributing private modules using version control systems that don't work well with zip files (related to cmd/go: add modvendor sub-command #27618).
To support those use-cases, I propose the following subcommands:
-
go mod pack [MODULE[@VERSION]] DIR: construct a module in the module cache from the module source code rooted atDIR(at versionVERSION). If theMODULEis omitted, it is inferred fromDIR/go.mod. If@VERSIONis provided, it must be a valid semantic version, andgo mod packfails if that version already exists with different contents. If@VERSIONis omitted,DIRmust be within a supported version control repository, andgo mod packwill attempt to infer the version from the repo state (commits and tags). -
go mod unpack MODULE[@VERSION] DIR: download the contents ofMODULEtoDIR. If@VERSIONis omitted, use the active version from the main module (if any), orlatestif no version is active. (In contrast togo mod vendor,go mod unpackwould unpack the entire contents of the module — not just the packages in the import graph of the main module.) -
go clean -m MODULE[@VERSION]: removeMODULE@VERSIONfrom the module cache. If run within a module, also remove the corresponding entry from itsgo.sumfile. If@VERSIONis omitted, remove all versions ofMODULEfrom the module cache (andgo.sumfile).
CC @hyangah @jadekler @rsc @myitcv @thepudds @rasky @rogpeppe @FiloSottile
Metadata
Metadata
Assignees
Labels
Type
Projects
Status