golang环境变量
Parsing environment variables with Go is simple, thanks to the standard library os
package.
借助标准库os
包,使用Go解析环境变量非常简单。
os.Getenv()
gets an environment variable. It’s not possible to determine not set or empty. Use os.LookupEnv()
to be able to do that.
os.Getenv()
获取一个环境变量。 无法确定未设置或为空。 使用os.LookupEnv()
能够做到这一点。
name := os.Getenv("NAME")
os.Setenv()
sets an environment variable.
os.Setenv()
设置环境变