utils

package
v9.6.15 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 23 Imported by: 5

Documentation

Index

Constants

View Source
const NbBytesWords = 4
View Source
const NbPinNumbers = 4

Variables

This section is empty.

Functions

func ByteCountDecimal

func ByteCountDecimal(b int64) string

ByteCountDecimal converts bytes to human readable byte string

func ChunkRangesToChunks

func ChunkRangesToChunks(chunkRanges []int64) (chunks []int64)

ChunkRangesToChunks converts chunk ranges to list

func Exists

func Exists(name string) bool

Exists reports whether the named file or directory exists.

func FindOpenPorts

func FindOpenPorts(host string, portNumStart, numPorts int) (openPorts []int)

func GenerateRandomPin

func GenerateRandomPin() string

func GetConfigDir added in v9.5.1

func GetConfigDir(requireValidPath bool) (homedir string, err error)

Get or create home directory

func GetInput

func GetInput(prompt string) string

GetInput returns the input with a given prompt

func GetLocalIPs

func GetLocalIPs() (ips []string, err error)

GetLocalIPs returns all local ips

func GetRandomName

func GetRandomName() string

GetRandomName returns mnemonicoded random name

func HashFile

func HashFile(fname string, algorithm string) (hash256 []byte, err error)

HashFile returns the hash of a file or, in case of a symlink, the SHA256 hash of its target. Takes an argument to specify the algorithm to use.

func IMOHashFile

func IMOHashFile(fname string) (hash []byte, err error)

IMOHashFile returns imohash

func IMOHashFileFull added in v9.1.1

func IMOHashFileFull(fname string) (hash []byte, err error)

IMOHashFileFull returns imohash of full file

func IsLocalIP

func IsLocalIP(ipaddress string) bool

func LocalIP

func LocalIP() string

LocalIP returns local ip address

func MD5HashFile

func MD5HashFile(fname string) (hash256 []byte, err error)

MD5HashFile returns MD5 hash

func MissingChunks

func MissingChunks(fname string, fsize int64, chunkSize int) (chunkRanges []int64)

MissingChunks returns the positions of missing chunks. If file doesn't exist, it returns an empty chunk list (all chunks). If the file size is not the same as requested, it returns an empty chunk list (all chunks).

func PublicIP

func PublicIP() (ip string, err error)

PublicIP returns public ip address

func RandomFileName

func RandomFileName() (fname string, err error)

func SHA256

func SHA256(s string) string

SHA256 returns sha256 sum

func UnzipDirectory added in v9.6.0

func UnzipDirectory(destination string, source string) error

func XXHashFile

func XXHashFile(fname string) (hash256 []byte, err error)

XXHashFile returns the xxhash of a file

func ZipDirectory added in v9.6.0

func ZipDirectory(destination string, source string) (err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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