utils

package
v10.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 26 Imported by: 0

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

GenerateRandomPin returns a randomly generated pin with set lenght

func GetConfigDir

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, showProgress ...bool) (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 HighwayHashFile added in v10.0.6

func HighwayHashFile(fname string, doShowProgress bool) (hashHighway []byte, err error)

HighwayHashFile returns highwayhash of a file

func IMOHashFile

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

IMOHashFile returns imohash

func IMOHashFileFull

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, doShowProgress bool) (hash256 []byte, err error)

MD5HashFile returns MD5 hash

func MarkFileForRemoval added in v10.0.13

func MarkFileForRemoval(fname string)

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 RemoveMarkedFiles added in v10.0.13

func RemoveMarkedFiles() (err error)

func SHA256

func SHA256(s string) string

SHA256 returns sha256 sum

func UnzipDirectory

func UnzipDirectory(destination string, source string) error

func ValidFileName

func ValidFileName(fname string) (err error)

ValidFileName checks if a filename is valid by making sure it has no invisible characters

func XXHashFile

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

XXHashFile returns the xxhash of a file

func ZipDirectory

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