Skip to content

proposal: cmd/go: change GO111MODULE=auto to have GO111MODULE=on behavior #78350

Description

@matloob

cc @golang/go-command

When modules were introduced our plan was initially to remove GOPATH mode behavior, but we decided to keep GOPATH mode indefinitely (#60915). This allows users to keep building very old Go code with new toolchains. While this isn't strictly required by our compatibility promises, it is certainly in the spirit of them. Given that we're keeping GOPATH mode indefinitely it would be helpful to simplify the decision of when they're run.

#60915 proposed to

Commit to preserving the ability to build GOPATH-layout source trees when GO111MODULE=off, indefinitely.

but it didn't directly mention GO111MODULE=auto mode itself. This proposal would make it so that GO111MODULE=auto mode is essentially "removed" by changing it to have the same behavior as GO111MODULE=on. This change would make it easier for the go command to know at startup time which mode it was operating in and would allow us to make some simplifications: for example, the toolchain selection code wouldn't need to do the check if it's in a module or workspace to determine its behavior, and knowing at startup time which mode we're in would allow us to do some more cleanups.

We've changed the meaning of GO111MODULE=auto before so that we wouldn't automatically enter GOPATH mode when we were in $GOPATH/src (#31857), so a change like this isn't totally without precedent (though of course it is far more broad).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status
    Status
    Hold

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions