utils

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SyncStderr = &SyncOutput{
	Mutex:  sync.Mutex{},
	output: os.Stderr,
}
View Source
var SyncStdout = &SyncOutput{
	Mutex:  sync.Mutex{},
	output: os.Stdout,
}

Functions

func ApplyMemoryLimit added in v1.0.8

func ApplyMemoryLimit()

func Collect added in v1.3.12

func Collect[K comparable](seq iter.Seq[K]) []K

func Deduplicate

func Deduplicate(s string) string

func DetectJSON added in v1.4.0

func DetectJSON(s io.ReaderAt) bool

DetectJSON weak detects if the given reader contains a JSON object

func FatalError added in v0.3.1

func FatalError(err error)

func GetImageBase

func GetImageBase(file *pe.File) uint64

func GetTableStyle added in v1.4.0

func GetTableStyle() table.Style

func GetURLFromListen added in v1.0.4

func GetURLFromListen(listen string) string

func InitLogger

func InitLogger(level slog.Level)

func Must added in v1.2.0

func Must(err error)

func Must2 added in v1.4.0

func Must2[T any](v T, err error) T

func PercentString added in v1.4.0

func PercentString(f float64) string

func PrefixToPath

func PrefixToPath(s string) (string, error)

PrefixToPath is the inverse of PathToPrefix, replacing escape sequences with the original character. from src/cmd/internal/objabi/path.go

func SortedKeys added in v1.0.0

func SortedKeys[T cmp.Ordered, U any](m map[T]U) []T

func UglyGuess

func UglyGuess(s string) string

UglyGuess an ugly hack for a known issue about golang compiler sees https://github.com/golang/go/issues/66313

func UsePanicForExit added in v1.0.5

func UsePanicForExit()

func WaitDebugger added in v1.6.3

func WaitDebugger(string)

WaitDebugger is a no-op on normal build

func WaitSignal

func WaitSignal()

WaitSignal waits for a Ctrl+C signal to exit the program.

Types

type ReaderAtAdapter added in v1.4.0

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

func NewReaderAtAdapter added in v1.4.0

func NewReaderAtAdapter(readerAt io.ReaderAt) *ReaderAtAdapter

func (*ReaderAtAdapter) Read added in v1.4.0

func (r *ReaderAtAdapter) Read(p []byte) (n int, err error)

type Set added in v1.0.11

type Set[T comparable] map[T]struct{}

func NewSet added in v1.0.11

func NewSet[T comparable]() Set[T]

func (Set[T]) Add added in v1.0.11

func (s Set[T]) Add(item T)

func (Set[T]) Contains added in v1.0.11

func (s Set[T]) Contains(item T) bool

func (Set[T]) Equals added in v1.4.0

func (s Set[T]) Equals(other Set[T]) bool

func (Set[T]) Remove added in v1.0.11

func (s Set[T]) Remove(item T)

func (Set[T]) ToSlice added in v1.0.11

func (s Set[T]) ToSlice() []T

type SyncOutput

type SyncOutput struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*SyncOutput) SetOutput

func (s *SyncOutput) SetOutput(output io.Writer)

func (*SyncOutput) Write

func (s *SyncOutput) Write(p []byte) (n int, err error)

type ValueOnce

type ValueOnce[T any] struct {
	*sync.Once
	// contains filtered or unexported fields
}

func NewOnce

func NewOnce[T any]() *ValueOnce[T]

func (*ValueOnce[T]) Get

func (o *ValueOnce[T]) Get() T

func (*ValueOnce[T]) Set

func (o *ValueOnce[T]) Set(v T)

Jump to

Keyboard shortcuts

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