os.LookupEnv将环境变量作为字符串和布尔值返回,指示变量是否已设置,因此您将获得v, ok = "something", true// or, if the env var isn't setv, ok = "", false// or, if the env var is set but empty:v, ok = "", true像这样使用它:var port stringvar ok boolif port, ok = os.LookupEnv("huru_api_port"); !ok { port = ":8000"}