Skip to content

proposal: Go Env : Add go.environment #57539

Not planned
Not planned
@Pat3ickI

Description

@Pat3ickI

As Go keep Growing the Go Environment Variables for Configuration is getting complex and their are some programs that requires specific configuration and it may mess up the default environment variables or tedious to setup so I propose we should add a file called go.environment which can be used instead of the default variables or the manual setup.
In the go.environment file

package < directory name > // package may not be needed 

version: < go version >

<go variable and their values>
goos: linux
goarch: ….
goroot: …..


when dealing with a variable that can accept multiple of Values

goexperiment: {
         boringcrypto, arena, unified 
         }

Or

goexperiment: { boringcrypto, arena, unified}

with the command go env init or go env init < directory >

Constraints
The go.environment file can either work or initiate if the directory does not contain package main in any go file since it won’t be useful for any libraries to have it

if GOOS=linux go build *.go This will argument will be treated first than what’s in the file.

We could add comments so it can be easy store some variables when needed // goos: then force the compiler to check for any empty variable goos:
or
If a variable is empty the compiler ignore it and use the default one

If there’s an invalid variable according to the go compiler version it’s either it ignore it or output an error

commands like go env goos=linux modify the file

Activity

added this to the Proposal milestone on Jan 1, 2023
seankhliao

seankhliao commented on Jan 1, 2023

@seankhliao
Member

Duplicate of #57179

locked and limited conversation to collaborators on Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gopherbot@seankhliao@Pat3ickI

        Issue actions

          proposal: Go Env : Add go.environment · Issue #57539 · golang/go