环境变量类

package
v0.0.0-...-2910145 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package genv 提供了对系统环境变量的操作。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToEnv别名

func MapToEnv别名(m map[string]string) []string

MapToEnv 将环境变量从映射转换为切片。

func Map到数组

func Map到数组(m map[string]string) []string

Build 函数用于构建一个映射到环境变量切片的映射。

func X删除

func X删除(名称 ...string) (错误 error)

Remove 删除一个或多个环境变量。

func X删除PANI

func X删除PANI(名称 ...string)

MustRemove 的行为与 Remove 相同,但是当发生任何错误时,它会触发 panic(异常)。

func X取Map

func X取Map() map[string]string

Map 返回一个字符串环境表示的映射副本。

func X取值

func X取值(名称 string, 默认值 ...interface{}) *泛型类.Var

Get 函数创建并返回一个 Var,其值为环境变量中名为 `key` 的变量的值。 如果该变量在环境中不存在,则使用给定的 `def` 作为默认值。

func X取值或命令行

func X取值或命令行(名称 string, 默认值 ...interface{}) *泛型类.Var

GetWithCmd returns the environment value specified `key`. If the environment value does not exist, then it retrieves and returns the value from command line options. It returns the default value `def` if none of them exists.

Fetching Rules: 1. Environment arguments are in uppercase format, eg: GF_<package name>_<variable name>; 2. Command line arguments are in lowercase format, eg: gf.<package name>.<variable name>;

func X取全部

func X取全部() []string

All 函数返回一个表示环境变量的字符串副本,其形式为 "key=value"。

func X数组到Map

func X数组到Map(数组 []string) map[string]string

MapFromEnv 将环境变量从切片转换为映射(map)。

func X数组去重

func X数组去重(数组 []string) []string

Filter 从给定的环境变量中过滤掉重复项。

func X是否存在

func X是否存在(名称 string) bool

Contains 检查名为 `key` 的环境变量是否存在。

func X设置Map值

func X设置Map值(m map[string]string) (错误 error)

SetMap 通过 map 设置环境变量。

func X设置值

func X设置值(名称, 值 string) (错误 error)

Set 函数用于设置名为 `key` 的环境变量的值。 如果出现错误,该函数会返回一个错误。

func X设置值PANI

func X设置值PANI(名称, 值 string)

MustSet 表现如同 Set,但当发生任何错误时会触发panic(异常)。

Types

This section is empty.

Jump to

Keyboard shortcuts

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