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:
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 at DIR (at version VERSION). If the MODULE is omitted, it is inferred from DIR/go.mod. If @VERSION is provided, it must be a valid semantic version, and go mod pack fails if that version already exists with different contents. If @VERSION is omitted, DIR must be within a supported version control repository, and go mod pack will attempt to infer the version from the repo state (commits and tags).
-
go mod unpack MODULE[@VERSION] DIR: download the contents of MODULE to DIR. If @VERSION is omitted, use the active version from the main module (if any), or latest if no version is active. (In contrast to go mod vendor, go mod unpack would unpack the entire contents of the module — not just the packages in the import graph of the main module.)
-
go clean -m MODULE[@VERSION]: remove MODULE@VERSION from the module cache. If run within a module, also remove the corresponding entry from its go.sum file. If @VERSION is omitted, remove all versions of MODULE from the module cache (and go.sum file).
CC @hyangah @jadekler @rsc @myitcv @thepudds @rasky @rogpeppe @FiloSottile
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:
go get -udo not introduce ambiguous imports #27899).replacedirectives).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