企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## Mix Dotenv 基于 [GoDotEnv](https://github.com/joho/godotenv) 开发的具有 **类型转换功能** 的环境配置库 Based on GoDotEnv library, with type conversion function ## Usage - 安装 ``` go get -u github.com/mix-go/dotenv ``` - 加载 `.env` 文件 不加载文件也可以获取系统环境变量,`Load` 方法并不是必须的 ~~~ err := dotenv.Load(".env") ~~~ - 获取环境配置 获取值 ~~~ dotenv.Getenv("key").String() dotenv.Getenv("key").Bool() dotenv.Getenv("key").Int64() dotenv.Getenv("key").Float64() ~~~ 获取值,当不存在时返回默认值 ~~~ dotenv.Getenv("key").String("default") dotenv.Getenv("key").Bool(false) dotenv.Getenv("key").Int64(123) dotenv.Getenv("key").Float64(123.4) ~~~ ## License Apache License Version 2.0, http://www.apache.org/licenses/