tools

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: BSD-2-Clause Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBottomLabel

func AddBottomLabel(fileName string, dstFileName string, label string) error

func AddDefaultVersion

func AddDefaultVersion(filename string, dstFileName string) error

func AddLabel

func AddLabel(img *image.RGBA, label string, x, y int)

func CheckCommand

func CheckCommand(cmd string) bool

func CreateDir

func CreateDir(dir string) (string, error)

CreateDir creates a directory if it does not exist, returning the final normalized directory as a result.

func CreateDirFromFilename

func CreateDirFromFilename(destination string, s string) (string, error)

func CreateFileWithDir

func CreateFileWithDir(destination string) (string, error)

CreateFileWithDir creates a file, relative to a directory, returning the final normalized path as a result.

func EncodeFileToBase64

func EncodeFileToBase64(filename string) (string, error)

func ExtractAllSubnets

func ExtractAllSubnets(text string) ([]*net.IPNet, error)

func FileExists

func FileExists(path string) bool

FileExists returns true if a path exists

func FileType

func FileType(path string) (string, error)

func Float64ToTime

func Float64ToTime(f float64) time.Time

Float64ToTime takes a float64 as number of seconds since unix epoch and returns time.Time

example field where this is used (expires field):

https://chromedevtools.github.io/devtools-protocol/tot/Network/#type-Cookie

func FormatCN

func FormatCN(cn string) string

func FormatInt

func FormatInt(n int) string

func FormatInt64

func FormatInt64(n int64) string

func GetHash

func GetHash(data []byte) string

func GetMimeType

func GetMimeType(s string) (string, error)

func HasBOM

func HasBOM(fileName string) bool

func IpTo24Net added in v0.1.3

func IpTo24Net(ip net.IP) *net.IPNet

func IpToUint32

func IpToUint32(ip net.IP) uint32

func IsSelfSigned

func IsSelfSigned(cert *x509.Certificate) bool

IsSelfSigned checks if a certificate is self-signed

func LeftTrucate

func LeftTrucate(s string, max int) string

LeftTrucate a string if its more than max

func MoveFile

func MoveFile(sourcePath, destPath string) error

MoveFile moves a file from a to b

func ParseCertificatePEM

func ParseCertificatePEM(pemData string) (*x509.Certificate, error)

func RandSleep

func RandSleep()

func RemoveFolder

func RemoveFolder(path string) error

func SafeFileName

func SafeFileName(s string) string

SafeFileName takes a string and returns a string safe to use as a file name.

func ShuffleLabeledIPs

func ShuffleLabeledIPs(ips []LabeledIP)

Shuffle slice of LabeledIP

func ShuffleStr

func ShuffleStr(slice []string)

ShuffleStr shuffles a slice of strings

func SliceHasInt

func SliceHasInt(slice []int, item int) bool

SliceHasInt checks if a slice has an int

func SliceHasStr

func SliceHasStr(slice []string, item string) bool

SliceHasStr checks if a slice has a string

func SliceHasUInt

func SliceHasUInt(slice []uint, item uint) bool

SliceHasInt checks if a slice has an int

func SliceHasUInt16

func SliceHasUInt16(slice []uint16, item uint16) bool

SliceHasInt checks if a slice has an int

func SubnetHosts

func SubnetHosts(cidr string) ([]net.IP, error)

func SubnetToUint32

func SubnetToUint32(subNet net.IPNet) uint32

func TempFileName

func TempFileName(base_path, prefix, suffix string) string

func UniqueIntSlice

func UniqueIntSlice(slice []int) []int

UniqueIntSlice returns a slice of unique ints

func Unzip

func Unzip(src, dest string) error

Types

type LabeledIP

type LabeledIP struct {
	IP     net.IP
	Subnet string
}

func ExpandCIDR

func ExpandCIDR(cidr string) ([]LabeledIP, error)

Expand CIDR into usable IPs and return with its subnet label

Jump to

Keyboard shortcuts

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