github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/envcmd/env.go (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package envcmd implements the “go env” command.
     6  package envcmd
     7  
     8  import (
     9  	"github.com/shogo82148/std/io"
    10  
    11  	"github.com/shogo82148/std/cmd/go/internal/base"
    12  	"github.com/shogo82148/std/cmd/go/internal/cfg"
    13  )
    14  
    15  var CmdEnv = &base.Command{
    16  	UsageLine: "go env [-json] [-u] [-w] [var ...]",
    17  	Short:     "print Go environment information",
    18  	Long: `
    19  Env prints Go environment information.
    20  
    21  By default env prints information as a shell script
    22  (on Windows, a batch file). If one or more variable
    23  names is given as arguments, env prints the value of
    24  each named variable on its own line.
    25  
    26  The -json flag prints the environment in JSON format
    27  instead of as a shell script.
    28  
    29  The -u flag requires one or more arguments and unsets
    30  the default setting for the named environment variables,
    31  if one has been set with 'go env -w'.
    32  
    33  The -w flag requires one or more arguments of the
    34  form NAME=VALUE and changes the default settings
    35  of the named environment variables to the given values.
    36  
    37  For more about environment variables, see 'go help environment'.
    38  	`,
    39  }
    40  
    41  func MkEnv() []cfg.EnvVar
    42  
    43  // ExtraEnvVars returns environment variables that should not leak into child processes.
    44  func ExtraEnvVars() []cfg.EnvVar
    45  
    46  // ExtraEnvVarsCostly returns environment variables that should not leak into child processes
    47  // but are costly to evaluate.
    48  func ExtraEnvVarsCostly() []cfg.EnvVar
    49  
    50  // PrintEnv prints the environment variables to w.
    51  func PrintEnv(w io.Writer, env []cfg.EnvVar)