myitcv / gobin

gobin is an experimental, module-aware command to install/run main packages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

-m flag tweak; emulate cmd/go's -mod=X?

myitcv opened this issue · comments

Currently the -m flag is documented as:

By default, gobin will use the main package's module to resolve its
dependencies, unless the -m flag is specified, in which case dependencies will
be resolved using the main module (as given by go env GOMOD).

It already feels like we need to emulate the -mod flag from cmd/go's modules support:

The -mod build flag provides additional control over updating and use of go.mod.

If invoked with -mod=readonly, the go command is disallowed from the implicit
automatic updating of go.mod described above. Instead, it fails when any changes
to go.mod are needed. This setting is most useful to check that go.mod does
not need updates, such as in a continuous integration and testing system.
The "go get" command remains permitted to update go.mod even with -mod=readonly,
and the "go mod" commands do not take the -mod flag (or any other build flags).

If invoked with -mod=vendor, the go command assumes that the vendor
directory holds the correct copies of dependencies and ignores
the dependency descriptions in go.mod.

Certainly the semantics offered by -mod=readonly seem to make sense.

Unsure at this point about -mod=vendor.

So this issue is about:

  • possible renaming -m to -mod
  • having the newly named -mod work in multiple modes:
    • -mod - use the main module for resolutions, changes allowed
    • -mod=readonly - use the main module for resolutions, changes not allowed

cc @rogpeppe @mvdan

This just got resolved by #43