env

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 7 Imported by: 0

README

Sourcegraph GoDoc Go Report Card License

Installation

go get github.com/tint/env

初始化

自动检测应用目录

env.Setup()

自定义启动目录

env.Setup("path/to/directory")

获取值

  env.Lookup(name string) (val string, exists bool)
  env.Exists(name string) bool
  env.Unknown(name string, value ...interface{}) interface{}
  env.String(name string, value ...string) string
  env.Bytes(name string, value ...[]byte) []byte
  env.Int(name string, value ...int) int
  env.Duration(name string, value ...time.Duration) time.Duration
  env.Bool(name string, value ...bool) bool
  env.Map(prefix string) map[string]string
  env.Where(filter func(name string, value string) bool) map[string]string
  env.Environ() []string

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RootPath string
	AppEnv   string
)

Functions

func Bool

func Bool(name string, value ...bool) bool

func Bytes

func Bytes(name string, value ...[]byte) []byte

func Duration

func Duration(name string, value ...time.Duration) time.Duration

func Environ

func Environ() []string

func Exists

func Exists(name string) bool

func Int

func Int(name string, value ...int) int

func Lookup

func Lookup(name string) (val string, exists bool)

func Map

func Map(prefix string) map[string]string

func Path

func Path(paths ...string) string

Path 根据应用根目录获取路径

func Setup

func Setup(root ...string)

func String

func String(name string, value ...string) string

func Unknown

func Unknown(name string, value ...interface{}) interface{}

func Where

func Where(filter func(name string, value string) bool) map[string]string

Types

This section is empty.

Jump to

Keyboard shortcuts

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