utils

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToInt64

func BytesToInt64(buf []byte) int64

func CopyFile

func CopyFile(dst, src string) error

func DirDirs

func DirDirs(path string, count uint32) ([]string, error)

Get the total size of all files in a directory and subdirectories

func DirFiles

func DirFiles(path string, count uint32) ([]string, error)

Get the total size of all files in a directory and subdirectories

func FildIpv4

func FildIpv4(data []byte) (string, bool)

func FindFile

func FindFile(dir, name string) string

func GetDirFreeSpace

func GetDirFreeSpace(dir string) (uint64, error)

func GetDirUsedSpace added in v0.4.2

func GetDirUsedSpace(dir string) (uint64, error)

func GetFileType

func GetFileType(fSrc string) (string, error)

func GetPublicIP

func GetPublicIP() (string, error)

func GetSysMemAvailable

func GetSysMemAvailable() (uint64, error)

func Int64ToBytes

func Int64ToBytes(i int64) []byte

func InterfaceIsNIL

func InterfaceIsNIL(i interface{}) bool

InterfaceIsNIL returns the comparison between i and nil

func IsIntranetIpv4

func IsIntranetIpv4(ipv4 string) (bool, error)

func PasswdWithMask

func PasswdWithMask(hint string, defaultVal string, mask string) (string, error)

func RandSlice

func RandSlice(slice interface{})

func RecoverError

func RecoverError(err interface{}) string

RecoverError is used to record the stack information of panic

func RemoveRepeatedAddr

func RemoveRepeatedAddr(arr []multiaddr.Multiaddr) (newArr []multiaddr.Multiaddr)

func RenameDir

func RenameDir(oldDir, newDir string) error

func StringBuilder

func StringBuilder(cap int, p ...string) string

func Ternary

func Ternary(a, b int64) int64

func VerifyPolkadotjsHexSign

func VerifyPolkadotjsHexSign(account, msg, signature string) ([]byte, bool, error)

VerifyPolkadotjsHexSign verify signature signed with polkadot.js

  • account: polkadot account
  • msg: message
  • sign: signature

Return:

  • []byte: public key of account
  • bool: verification result
  • error: error message

Tip:

func VerifySR25519WithPubkey

func VerifySR25519WithPubkey(account, msg, signature string) ([]byte, bool, error)

VerifySR25519WithPubkey verify sr25519 signature with account public key

  • account: polkadot account
  • msg: message
  • signature: sr25519 signature

Return:

  • []byte: public key of account
  • bool: verification result
  • error: error message

Types

This section is empty.

Jump to

Keyboard shortcuts

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