Documentation
¶
Index ¶
- func ArchAlias(arch string) string
- func Bcrypt(password string) (string, error)
- func ChangeDir(path string) error
- func CopyDirectory(src, dst string) error
- func CopyDirectoryIfExists(src, dstDir string) error
- func CopyFile(src, dst string) error
- func CopyFileToDir(src, dir string) error
- func CountDirFiles(dirName string) int
- func CreateDir(path string) error
- func Exec(ctx context.Context, name string, printOutput bool, printLine bool) (stdout string, code int, err error)
- func ExecWithContext(ctx context.Context, name string, printOutput bool, printLine bool) (stdout string, code int, err error)
- func FileMD5(path string) (string, error)
- func FormatBytes(bytes int64) string
- func FormatSed(darwin bool) string
- func GetArgs(argsMap map[string]string, args []string) ([]string, map[string]string)
- func GetAvailableIP(ipAndMask string) []string
- func GetAvailableIPRange(ipStart, ipEnd string) []string
- func GetCommand(c string) (string, error)
- func GetCpu() (string, int, int, error)
- func GetDisk() (uint64, uint64, error)
- func GetFs() (string, string, error)
- func GetHost() ([]string, error)
- func GetLocalIP() (net.IP, error)
- func GetMem() (uint64, uint64, error)
- func GetNet()
- func GetPs() ([]disk.PartitionStat, error)
- func GetPublicIPFromAWSIMDS() (net.IP, error)
- func GetPublicIPFromAliyunIMDS() (net.IP, error)
- func GetPublicIPFromTencentIMDS() (net.IP, error)
- func GetPublicIPsFromOS() ([]net.IP, error)
- func GetTokenFROMAWSIMDS() (string, error)
- func GetTokenFromAliyunIMDS() (string, error)
- func GetValidIPv4AddrsFromOS() ([]net.IP, error)
- func Home() (string, error)
- func IPAddressToCIDR(ipAddress string) string
- func IPMaskStringToCIDR(netmask string) string
- func IsDir(path string) bool
- func IsExecutable(path string) bool
- func IsExist(path string) bool
- func IsOnAWSEC2() bool
- func IsOnAliyunECS() bool
- func IsOnTencentCVM() bool
- func IsValidIPv4Addr(ip net.IP) bool
- func LocalMd5Sum(src string) string
- func MkFileFullPathDir(fileName string) error
- func Mkdir(dirName string) error
- func MoveDirectory(src, dst string) error
- func MoveFile(src, dst string) error
- func ParseIp(ip string) []string
- func RemoveDir(path string) error
- func RemoveFile(path string) error
- func RemoveHTTPPrefix(url string) string
- func Render(tmpl *template.Template, variables any) (string, error)
- func ReplaceInFile(filepath, old, new string) error
- func Round(val float64, precision int) float64
- func Sha256sum(path string) (string, error)
- func ShortDur(d time.Duration) string
- func Tar(src, dst, trimPrefix string) error
- func Untar(src, dst string) error
- func WriteFile(fileName string, content []byte, perm os.FileMode) error
- type Data
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDirectory ¶
func CopyDirectoryIfExists ¶
func CopyFileToDir ¶
func CountDirFiles ¶
func ExecWithContext ¶
func FormatBytes ¶
func GetAvailableIP ¶
func GetAvailableIPRange ¶
func GetCommand ¶
func GetLocalIP ¶
GetLocalIP gets the local ip either by getting the "OS_LOCALIP" environment variable or by resolving the local hostname to IP address if the env is not set in both cases, the IP address is matched against the valid addresses of the local interfaces to check if it is an actually bindable address by valid it means the address is a non-loopback IPv4 address the explicitly specified env var takes precedence than the hostname if a valid IP is not found in both cases, a default IP is selected as a fallback
func GetPs ¶
func GetPs() ([]disk.PartitionStat, error)
func GetPublicIPFromAWSIMDS ¶
func GetPublicIPsFromOS ¶
GetPublicIPsFromOS gets a list of public ips by looking at the local network interfaces if any
func GetTokenFROMAWSIMDS ¶
func GetTokenFromAliyunIMDS ¶
func GetValidIPv4AddrsFromOS ¶
func IPAddressToCIDR ¶
func IPMaskStringToCIDR ¶
func IsExecutable ¶
func IsOnAWSEC2 ¶
func IsOnAWSEC2() bool
func IsOnAliyunECS ¶
func IsOnAliyunECS() bool
func IsOnTencentCVM ¶
func IsOnTencentCVM() bool
func IsValidIPv4Addr ¶
func LocalMd5Sum ¶
func MkFileFullPathDir ¶
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.