env

package
v0.0.0-...-2a644cb Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package env 提供一些环境变量相关的工具

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBool

func GetBool(key string) bool

GetBool 获取 bool 类型环境变量。大于零的值均会被视为 true, 字符串 true 和 TRUE 也会视为 true。 剩余情况 (包括不存在) 则返回 false

func GetInt

func GetInt[T Integer](key string, fallback T) T

GetInt 获取 int 类型环境变量, 如果环境变量不存在或非法则返回默认值

func GetString

func GetString(key string, fallback string) string

GetString 获取 string 类型环境变量, 如果环境变量不存在则返回默认值

func GetUint

func GetUint[T Unsigned](key string, fallback T) T

GetUint 获取 uint 类型环境变量, 如果环境变量不存在或非法则返回默认值

Types

type Integer

type Integer interface {
	Signed | Unsigned
}

type Signed

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

Jump to

Keyboard shortcuts

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