util

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(a string) string

Escape * Tab is escaped as `\t`. * Carriage return is escaped as `\r`. * Line feed is escaped as `\n`. * Single quote is escaped as `\'`. * Double quote is escaped as `\"`. * Backslash is escaped as `\\`.

func GenRandomData added in v0.28.0

func GenRandomData(n int) []byte

func IsExecutable

func IsExecutable(file os.FileInfo) bool

func IsExecutableMode

func IsExecutableMode(mode os.FileMode) bool
func IsSymLink(file os.FileInfo) bool

func IsSymLinkMode

func IsSymLinkMode(mode os.FileMode) bool
func MakeLink(abs string, name string) string

func RecursivelySizeOf

func RecursivelySizeOf(info *item.FileInfo, depth int) int64

RecursivelySizeOf returns the size of the file or directory depth < 0 means no limit

func RecursivelySizeOfGenerator added in v0.28.0

func RecursivelySizeOfGenerator(afs afero.Fs) func(info *item.FileInfo, depth int) int64

func RemoveSep

func RemoveSep(s string) string

func SplitNumberAndUnit added in v0.27.0

func SplitNumberAndUnit(input string) (float64, string)

SplitNumberAndUnit splits a string like "10bit" to 10 and "bit"

"12.3ml" to 12.4 and "ml"

"-1,234,213kg" to -1234213 and "kg"

Types

type MockFileInfo added in v0.28.0

type MockFileInfo struct {
	// contains filtered or unexported fields
}

func NewMockFileInfo added in v0.28.0

func NewMockFileInfo(size int64, isDir bool, name string, mode os.FileMode, modTime time.Time) *MockFileInfo

func (*MockFileInfo) IsDir added in v0.28.0

func (m *MockFileInfo) IsDir() bool

func (*MockFileInfo) ModTime added in v0.28.0

func (m *MockFileInfo) ModTime() time.Time

func (*MockFileInfo) Mode added in v0.28.0

func (m *MockFileInfo) Mode() os.FileMode

func (*MockFileInfo) Name added in v0.28.0

func (m *MockFileInfo) Name() string

func (*MockFileInfo) Size added in v0.28.0

func (m *MockFileInfo) Size() int64

func (*MockFileInfo) Sys added in v0.28.0

func (m *MockFileInfo) Sys() any

type Once

type Once struct {
	// contains filtered or unexported fields
}

func (*Once) Do

func (o *Once) Do(fn func() error) error

type SafeSet

type SafeSet[T constval.Hashable] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T constval.Hashable]() *SafeSet[T]

func (*SafeSet[T]) Add

func (s *SafeSet[T]) Add(k T)

func (*SafeSet[T]) Contains

func (s *SafeSet[T]) Contains(k T) bool

type Slice

type Slice[T any] struct {
	// contains filtered or unexported fields
}

func NewSlice

func NewSlice[T any](size int) *Slice[T]

func (*Slice[T]) AppendTo

func (s *Slice[T]) AppendTo(d T)

func (*Slice[T]) At

func (s *Slice[T]) At(pos int) T

func (*Slice[T]) Clear

func (s *Slice[T]) Clear()

func (*Slice[T]) GetCopy

func (s *Slice[T]) GetCopy() []T

func (*Slice[T]) GetRaw

func (s *Slice[T]) GetRaw() *[]T

func (*Slice[T]) Len

func (s *Slice[T]) Len() int

func (*Slice[T]) Set

func (s *Slice[T]) Set(pos int, d T)

Jump to

Keyboard shortcuts

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