common

package
v0.0.0-...-528a4c1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
	TiByte
	PiByte
	EiByte
)

IEC Sizes. kibis of bits

View Source
const (
	IByte = 1
	KByte = IByte * 1000
	MByte = KByte * 1000
	GByte = MByte * 1000
	TByte = GByte * 1000
	PByte = TByte * 1000
	EByte = PByte * 1000
)

SI Sizes.

View Source
const BackupSuffix = "~"

Variables

This section is empty.

Functions

func Backup

func Backup(path string) error

func Bytes

func Bytes(s uint64) string

Bytes produces a human readable representation of an SI size.

See also: ParseBytes.

Bytes(82854982) -> 83 MB

func BytesShort

func BytesShort(s uint64) string

func CheckSumCompare

func CheckSumCompare(t string, w io.Writer, flagSet *flag.FlagSet, suppress bool) error

func CheckSumMain

func CheckSumMain(t string, w io.Writer, flagSet *flag.FlagSet, suppress bool) error

func Checksum

func Checksum(t string, fp io.Reader) (string, error)

func CompareSlice

func CompareSlice(s1, s2 []byte) (int, bool)

func ConvertFileModeStr

func ConvertFileModeStr(mode string) (os.FileMode, error)

func FileExists

func FileExists(path string) bool

func FileNotExists

func FileNotExists(path string) bool

func IBytes

func IBytes(s uint64) string

IBytes produces a human readable representation of an IEC size.

See also: ParseBytes.

IBytes(82854982) -> 79 MiB

func IntContains

func IntContains(target []int, src int) bool

IntContains checks the src in any int of the target int slice.

func IsDir

func IsDir(name string) (bool, error)

func IsHidden

func IsHidden(name string) bool

func IsMalformedFileMode

func IsMalformedFileMode(mode os.FileMode) bool

func IsNamedPipe

func IsNamedPipe(info os.FileInfo) bool

func IsNumber

func IsNumber(s string) (int, bool)
func IsSymlink(info os.FileInfo) bool

func OpenTwoFiles

func OpenTwoFiles(files []string) (sf *os.File, df *os.File, err error)

func ParseBytes

func ParseBytes(s string) (uint64, error)

ParseBytes parses a string representation of bytes into the number of bytes it represents.

See Also: Bytes, IBytes.

ParseBytes("42 MB") -> 42000000, nil ParseBytes("42 mib") -> 44040192, nil

func ReadWholeLine

func ReadWholeLine(b *bufio.Reader) (line string, err error)

func StringsContains

func StringsContains(target []string, src string) bool

StringsContains checks the src in any string of the target string slice

func StringsHas

func StringsHas(target []string, src string) bool

StringsHas checks the target string slice contains src or not

func UniqSortInt

func UniqSortInt(src []int) []int

func Walk

func Walk(path string, info os.FileInfo, depth int, parentIgnores IgnoreMatchers, followed bool, walkFn walkFunc) error

func WrapString

func WrapString(src string, lim int, delim string) string

Types

type IgnoreMatcher

type IgnoreMatcher interface {
	Match(path string, isDir bool) bool
}

type IgnoreMatchers

type IgnoreMatchers []IgnoreMatcher

func (IgnoreMatchers) Match

func (im IgnoreMatchers) Match(path string, isDir bool) bool

Jump to

Keyboard shortcuts

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