helper

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareVersion added in v0.1.0

func CompareVersion(version1, version2 string) int

CompareVersion 版本号对比 两版本相同时返回0, version1 > version2时返回1, version1 < version2时返回-1

func Copy added in v0.1.0

func Copy(src string, dest string) error

Copy copies from src to dest

func ExpandEnv

func ExpandEnv(s string) string

ExpandEnv 寻找s中的 ${var} 并替换为环境变量的值,没有则替换为空,不解析 $var

os.ExpandEnv会同时处理${var}和$var,配置文件中可能包含一些含特殊字符$的配置项, 如redisClient、mysqlClient的连接密码。

func GetEnvName

func GetEnvName(s string) (string, int)

GetEnvName 获取环境变量名,即${var}里面的var内容,返回var内容及其长度

func GetGlobalConfig added in v1.0.0

func GetGlobalConfig() any

GetGlobalConfig 获取全局配置

func HideSecret

func HideSecret(secret string, count uint32) string

HideSecret 隐藏字符串的中间字符

func InArray

func InArray(target interface{}, array interface{}) bool

InArray 判断目标是否存在于数组当中

func LoadConfigWithObj

func LoadConfigWithObj(path string, obj interface{}) error

LoadConfigWithObj 加载配置并解析到obj

func SetGlobalConfig added in v1.0.0

func SetGlobalConfig(cfg any)

SetGlobalConfig 存储到全局配置

func Unarchive added in v0.1.0

func Unarchive(src string, dest string) error

解压缩tgz压缩包

Types

type Config

type Config map[string]yaml.Node

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig 加载配置文件内容

func (Config) DecodeNode

func (c Config) DecodeNode(name string, v interface{}) error

DecodeNode 解析节点内容

Jump to

Keyboard shortcuts

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