os包 func Getenv(key string) string func Environ() []string
package main import ( "fmt" "os" ) func main(){ fmt.Println(os.Getenv("HOME")) fmt.Println(os.Getenv("USER")) values := os.Environ() for _, value := range values{ fmt.Println(value) } }
https://gitee.com/dyyx/hellocode/blob/master/7days-golang/demo/envdemo.go