utils

package
v0.15.12 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AES_CBC_Decrypt

func AES_CBC_Decrypt(data string, key []byte) []byte

AES_CBC_Decrypt AEC解密(CBC模式)

func AES_CBC_Encrypt

func AES_CBC_Encrypt(plainText []byte, key []byte) string

AES_CBC_Encrypt AEC加密(CBC模式)

func B64Decode

func B64Decode(input string) ([]byte, error)

func B64DecodeString added in v0.9.0

func B64DecodeString(input string) (string, error)

B64Decode base64解密

func B64Encode

func B64Encode(input []byte) string

B64Encode base64加密

func CheckFileIsExist

func CheckFileIsExist(filename string) bool

CheckFileIsExist 判断文件是否存在 存在返回 true 不存在返回false

func CheckObjectives added in v0.11.1

func CheckObjectives(objectives string) bool

CheckObjectives 检查prometheus objectives配置 校验0.5:0.1,0.9:0.001的格式

func CheckUrlPath added in v0.11.1

func CheckUrlPath(path string) bool

func ConvertArray

func ConvertArray(arr []string) (bool, []int)

ConvertArray 将[]string转为[]int

func ConvertIntArrayToString

func ConvertIntArrayToString(ids []int) string

ConvertIntArrayToString 转换整型数组

func CopyMaps added in v0.10.0

func CopyMaps[K comparable, T any](maps map[K]T) map[K]T

func GenFile

func GenFile(dir, fileName, data string) error

GenFile 根据路径和数据生成文件

func GetMac

func GetMac() (bool, string)

GetMac 获取MAC地址

func GetRandomString

func GetRandomString(num int) string

GetRandomString 生成随机字符串

func GetRandomStringBack

func GetRandomStringBack(num int) string

GetRandomStringBack 生成随机字符串

func GzipCompress

func GzipCompress(origin []byte) ([]byte, error)

GzipCompress 转成Gzip

func HMacBySha256

func HMacBySha256(key, toSign string) string

HMacBySha256 HMacBySha256

func HeaderToString

func HeaderToString(h http.Header) string

HeaderToString 将header转成字符串

func HexEncode

func HexEncode(body []byte) string

HexEncode HexEncode

func Intercept

func Intercept(str, substr string) (string, string)

Intercept 获取IP

func InterfaceToString added in v0.10.0

func InterfaceToString(value interface{}) string

func IsMatchDomainPort added in v0.12.1

func IsMatchDomainPort(s string) bool

IsMatchDomainPort 判断字符串是否符合 域名或者域名:port

func IsMatchIpPort added in v0.12.1

func IsMatchIpPort(s string) bool

IsMatchIpPort 判断字符串是否符合 ip:port或者ip

func IsMatchSchemeDomainPort added in v0.12.1

func IsMatchSchemeDomainPort(s string) bool

IsMatchSchemeDomainPort 判断字符串是否符合 scheme://域名或者域名:port

func IsMatchSchemeIpPort added in v0.12.1

func IsMatchSchemeIpPort(s string) bool

IsMatchSchemeIpPort 判断字符串是否符合scheme://ip:port

func JSONUnmarshal

func JSONUnmarshal(s, v interface{}) error

JSONUnmarshal 将json格式的s解码成v所需的json格式

func JSObjectToJSON

func JSObjectToJSON(s string) ([]byte, error)

JSObjectToJSON 将js对象转为json

func JsonSchemaMockJsUnmarshal added in v0.12.1

func JsonSchemaMockJsUnmarshal(valueMap interface{}) interface{}

JsonSchemaMockJsUnmarshal 解析mockJs生成的json schema 并根据规则生成随机值 不是mockJs生成的json 走默认规则解析

func Md5

func Md5(encodeString string) string

Md5 md5加密

func MustSliceString

func MustSliceString(v interface{}) ([]string, error)

MustSliceString 断言输入的参数为字符串切片

func Padding

func Padding(plainText []byte, blockSize int) []byte

Padding 对明文进行填充

func QueryUrlEncode

func QueryUrlEncode(rawQuery string) string

QueryUrlEncode 对query进行url encode

func RandFloats added in v0.12.1

func RandFloats(min, max float64) float64

func RandInt64 added in v0.12.1

func RandInt64(min, max int64) int64

func SSHClient

func SSHClient(user, password, host, key string, port int, cipherList []string) (*ssh.Client, error)

SSHClient SSHClient

func Scan added in v0.15.12

func Scan(src []interface{}, dest ...interface{}) ([]interface{}, error)

Scan copies from src to the values pointed at by dest.

Scan uses RedisScan if available otherwise:

The values pointed at by dest must be an integer, float, boolean, string, []byte, interface{} or slices of these types. Scan uses the standard strconv package to convert bulk strings to numeric and boolean types.

If a dest value is nil, then the corresponding src value is skipped.

If a src element is nil, then the corresponding dest value is not modified.

To enable easy use of Scan in a loop, Scan returns the slice of src following the copied values.

func SessionConnect

func SessionConnect(client *ssh.Client) (*ssh.Session, error)

SessionConnect SessionConnect

func SftpConnect

func SftpConnect(client *ssh.Client) (*sftp.Client, error)

SftpConnect SftpConnect

func Stop

func Stop() bool

Stop 关闭网关服务,重启读取配置文件

func TrimPrefixAll

func TrimPrefixAll(s string, r string) string

TrimPrefixAll 删除所有前缀

func TrimSuffixAll

func TrimSuffixAll(s string, r string) string

TrimSuffixAll 删除所有后缀

func UnPadding

func UnPadding(cipherText []byte) []byte

UnPadding 对密文删除填充

func ValidateRemoteAddr

func ValidateRemoteAddr(ip string) bool

ValidateRemoteAddr 判断ip端口是否合法

func ValidateURL

func ValidateURL(url string) bool

ValidateURL 判断ip端口是否合法

Types

type Error added in v0.15.12

type Error string

func (Error) Error added in v0.15.12

func (err Error) Error() string

type Scanner added in v0.15.12

type Scanner interface {
	// RedisScan assigns a value from a Redis value. The argument src is one of
	// the reply types listed in the section `Executing Commands`.
	//
	// An error should be returned if the value cannot be stored without
	// loss of information.
	RedisScan(src interface{}) error
}

type SftpClient

type SftpClient struct {
	// contains filtered or unexported fields
}

SftpClient sftp客户端

func NewSftpClient

func NewSftpClient(client *ssh.Client) (*SftpClient, error)

NewSftpClient new sftp客户端

func (*SftpClient) CheckPathIsExisted

func (s *SftpClient) CheckPathIsExisted(path string) error

CheckPathIsExisted CheckPathIsExisted

func (*SftpClient) Close

func (s *SftpClient) Close() error

Close Close

func (*SftpClient) Finish

func (s *SftpClient) Finish() error

Finish Finish

func (*SftpClient) GetProcess

func (s *SftpClient) GetProcess() string

GetProcess GetProcess

func (*SftpClient) ScpCopy

func (s *SftpClient) ScpCopy(localFilePath, remoteDir string) error

ScpCopy scp复制

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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