Skip to content

cmd/go: support quotes in GOENV file #80056

Description

@AlekSi

I read the following documentation sections, among others:

They don't explicitly say if quotes in the GOENV file are supported, but the last link kind of implies that with

GOSUMDB="sum.golang.org"
GOSUMDB="sum.golang.org+<publickey>"
GOSUMDB="sum.golang.org+<publickey> https://sum.golang.org"
[...]
The go env -w command can be used to set these variables for future go command invocations.

Unfortunately, quotes are not supported.

I think they should be, because that would allow storing project-specific Go configuration in the repository and using it as a GOENV file for Go, for Dependabot, and for various dotenv tools like https://direnv.net with a simple dotenv go.env. GOSUMDB=sum.golang.org https://sum.golang.org without quotes is not supported by direnv ("direnv: error invalid line: GOSUMDB=sum.golang.org https://sum.golang.org"), and quotes make the GOENV file invalid for Go.

Only simple double quotes support is needed, without escaping or anything else.

Alternatively, a space in this GOSUMDB form could be replaced by something else, like , or |, but that would look like multiple GOSUMDBs, like multiple Go proxies are allowed in GORPOXY.

Alternatively alternatively, documentation could be tweaked to explicitly say that quotes are not supported. But that would be the least preferable option for me.

For reference, that's my GOENV file:

GOPROXY=https://corp-proxy/go-proxy|https://proxy.golang.org
GOSUMDB=sum.golang.org https://sum.golang.org
GOPRIVATE=github.com/corp

This form of GOSUMDB is required to use sum.golang.org directly instead of via the corp-proxy, which is not available in some contexts where this file is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions