dotenv

package module
v1.1.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 3 Imported by: 3

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/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Getenv

func Getenv(key string) *envValue

Getenv 获取环境变量

func Load

func Load(filenames ...string) (err error)

Load will read your env file(s) and load them into ENV for this process.

func Overload added in v1.1.14

func Overload(filenames ...string) (err error)

Overload will read your env file(s) and load them into ENV for this process.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL