utils

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 21 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTemplate

func ApplyTemplate(temp string, data map[string]interface{}) (string, error)

渲染模板

func ContainsString

func ContainsString(slice []string, s string) bool

func DecodeBase64

func DecodeBase64(in string) (string, error)

解密base64

func DelMapElement

func DelMapElement(m map[string]string, key string)

func DiffSlice

func DiffSlice(oldSlice, newSlice []string) (deletes, adds []string)

DiffSlice 返回old存在但是new中不存在的数组(deletes) + new中存在但是old中不存在的数组(adds)

func DiffString

func DiffString(oldS, newS, separator string) (deletes, adds []string)

DiffString 按separator分割oldS+newS oldS 中存在newS中不存在的放到deletes数组 newS 中存在oldS中不存在的放到adds数组

func EncodeBase64

func EncodeBase64(in string) string

加密base64

func ExecCommand

func ExecCommand(cmd string) ([]byte, error)

func ExecCommandString

func ExecCommandString(cmd string) (string, error)

func GetCurrentDirectory

func GetCurrentDirectory() string

func GetIPs

func GetIPs() (ips []string)

func GetMacAddrs

func GetMacAddrs() (macAddrs []string)

0:cf:e0:44:dd:be,enp1s0

func GetRandomSalt

func GetRandomSalt() string

return len=8 salt

func GetRandomString

func GetRandomString(len int) string

生成随机字符串

func If

func If(condition bool, trueVal, falseVal interface{}) interface{}

If 实现三元表达式的功能

func In

func In(target string, source []string) bool

快速判断字符是否在字符数组中

func IsDir

func IsDir(path string) bool

func Jiami

func Jiami(code string) string

加密

func MD5

func MD5(text string) string

生成32位MD5

func ParseJson

func ParseJson(data string, header http.Header) (map[string]interface{}, error)

func SliceBothBySlice

func SliceBothBySlice(s1, s2 []string) []string

SliceBothBySlice 返回同时存在s1和s2数组

func SliceContainer

func SliceContainer(s []string, sub string) bool

SliceContainer 数组是否存在sub字符串

func SliceEqual

func SliceEqual(s1, s2 []string) bool

SliceEqual s1和s2数组是否数据一致 - 注意这里不判断顺序一致 只判断字符是否存在

func SliceJoinBySlice

func SliceJoinBySlice(s1, s2 []string) []string

SliceJoinBySlice 返回s1+s2数组 - 去重

func SliceOnlyBySlice

func SliceOnlyBySlice(s1, s2 []string) []string

SliceOnlyBySlice 返回s1存在但是s2不存在的数组

func SliceRemoveDuplication

func SliceRemoveDuplication(list []string) []string

SliceRemoveDuplication 数组去重: 顺序会乱

func SliceRemoveStr

func SliceRemoveStr(s []string, sub string) []string

SliceRemoveStr 删除数组中存在的str 返回返回剩余项

func WriteFile

func WriteFile(path string, data []byte) (int, error)

写文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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