util

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 23 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchAlias

func ArchAlias(arch string) string

ArchAlias returns the alias of cpu's architecture. amd64: x86_64 arm64: aarch64

func CountDirFiles

func CountDirFiles(dirName string) int

func CreateDir

func CreateDir(path string) error

func FileMD5

func FileMD5(path string) (string, error)

FileMD5 count file md5

func GetArgs

func GetArgs(argsMap map[string]string, args []string) ([]string, map[string]string)

func GetAvailableIP

func GetAvailableIP(ipAndMask string) []string

func GetAvailableIPRange

func GetAvailableIPRange(ipStart, ipEnd string) []string

func GetLocalIP

func GetLocalIP() (string, error)

func Home

func Home() (string, error)

Home returns the home directory for the executing user.

func IPAddressToCIDR

func IPAddressToCIDR(ipAddress string) string

func IPMaskStringToCIDR

func IPMaskStringToCIDR(netmask string) string

func IsDir

func IsDir(path string) bool

func IsExist

func IsExist(path string) bool

func LocalIP

func LocalIP() (localIp string)

func LocalMd5Sum

func LocalMd5Sum(src string) string

func MkFileFullPathDir

func MkFileFullPathDir(fileName string) error

MkFileFullPathDir is used to file create the full path. eg. there is a file "./aa/bb/xxx.txt", and dir ./aa/bb is not exist, and will create the full path dir.

func Mkdir

func Mkdir(dirName string) error

func ParseIp

func ParseIp(ip string) []string

func Render

func Render(tmpl *template.Template, variables map[string]interface{}) (string, error)

Render text template with given `variables` Render-context

func Round

func Round(val float64, precision int) float64

Round returns the result of rounding 'val' according to the specified 'precision' precision (the number of digits after the decimal point)。 and precision can be negative number or zero

func ShortDur

func ShortDur(d time.Duration) string

func Tar

func Tar(src, dst, trimPrefix string) error

func Untar

func Untar(src, dst string) error

func WriteFile

func WriteFile(fileName string, content []byte) error

Types

type Data

type Data map[string]interface{}

Jump to

Keyboard shortcuts

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