helper

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 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 GetConfigPath

func GetConfigPath() string

GetConfigPath 获取配置文件路径 默认为执行文件同级的config.yaml 也可通过 --c或者-c 传入配置文件路径

func GetEnvName

func GetEnvName(s string) (string, int)

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

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 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