25 Star 207 Fork 26

mix-go/mix

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

OpenMix 出品:https://openmix.org

Mix Dotenv

基于 GoDotEnv 开发的具有类型转换功能的环境配置库

Based on GoDotEnv library, with type conversion function

Installation

go get github.com/mix-go/dotenv

Usage

载入 .env 到环境变量

_ = dotenv.Load(".env")

获取环境变量

i := dotenv.Getenv("key").String()
i := dotenv.Getenv("key").Bool()
i := dotenv.Getenv("key").Int64()
i := dotenv.Getenv("key").Float64()

设置默认值

i := dotenv.Getenv("key").String("default")
i := dotenv.Getenv("key").Bool(false)
i := dotenv.Getenv("key").Int64(123)
i := dotenv.Getenv("key").Float64(123.4)

License

Apache License Version 2.0, http://www.apache.org/licenses/

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mix-go/mix.git
git@gitee.com:mix-go/mix.git
mix-go
mix
mix
master

搜索帮助