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

proposal: cmd/go: subcommands to add and remove modules from the module cache #28835

Open
bcmills opened this Issue Nov 16, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@bcmills
Member

bcmills commented Nov 16, 2018

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 (#27542, #27899).
  • Bootstrapping a server to serve the module containing itself (#28029, but that can be worked around using replace directives).
  • Storing and distributing private modules using version control systems that don't work well with zip files (related to #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 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

@bcmills

This comment has been minimized.

Member

bcmills commented Nov 16, 2018

A way to explicitly populate the module cache from source might also help in cases where the original source path is blocked or unavailable but the code is available from a trusted mirror (as in #28652).

@rsc

This comment has been minimized.

Contributor

rsc commented Nov 27, 2018

We have go mod download to add to the module cache.
We have go mod clean -modcache to clear it.
Do we really need more fine-grained control?
I fear that will make people manage it more.

@rsc

This comment has been minimized.

Contributor

rsc commented Nov 27, 2018

Never mind I didn't understand the problem being solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment