Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Coalesce

func Coalesce[T comparable](vs ...T) T

func FileExists

func FileExists(path string) (bool, error)

func FindGitIgnore

func FindGitIgnore(path string) (func(string) bool, error)

func First

func First[T any](l []T) T

func FirstUpper

func FirstUpper(str string) string

func IIf

func IIf[T any](test bool, ifTrue, ifFalse T) T

func In

func In[T comparable](v T, cs ...T) bool

func IsTextFile

func IsTextFile(path string) (bool, error)

func IsTextReader

func IsTextReader(reader io.ReadCloser, err error) (bool, error)

func IsTextReaderOpts

func IsTextReaderOpts(reader io.ReadCloser, err error, sampleLines int) (bool, error)

func IsTrue

func IsTrue(v string) bool

func Last

func Last[T any](l []T) T

func ListFilesRecursive

func ListFilesRecursive(rootDir string, matcher func(name string) bool) ([]string, error)

func MapContains

func MapContains[K comparable, V any](m map[K]V, k K) bool

func MapKeysHaveIntersection

func MapKeysHaveIntersection[K comparable, V1 any, V2 any](m1 map[K]V1, m2 map[K]V2) bool

func MapMapContains

func MapMapContains[K1, K2 comparable, V any](m1 map[K1]map[K2]V, k1 K1, k2 K2) bool

func Max

func Max[T constraints.Ordered](a T, bs ...T) T

func Min

func Min[T constraints.Ordered](a T, bs ...T) T

func NewProgressBar

func NewProgressBar(total int) *progressbar.ProgressBar

func PathAbs

func PathAbs(paths ...string) (string, error)

func RemoveLast

func RemoveLast[T any](l []T) []T

func Take

func Take[T any](l []T, i int) []T

func TruncateFilename

func TruncateFilename(name string) string

Types

type ParallelOptions

type ParallelOptions struct {
	Routines     int
	InputFactor  int
	OutputFactor int
}

type ProcessGroup

type ProcessGroup[I, O any] struct {
	Input  chan I
	Output chan O
	Err    chan error
	// contains filtered or unexported fields
}

func NewProcessGroup

func NewProcessGroup[I, O any](proc func(I) (O, error), opts ...ParallelOptions) *ProcessGroup[I, O]

func ParallelFor

func ParallelFor[T, O any](col []T, proc func(T) (O, error), opts ...ParallelOptions) *ProcessGroup[T, O]

func (*ProcessGroup[I, O]) Abort

func (g *ProcessGroup[I, O]) Abort(err error)

func (*ProcessGroup[I, O]) Aborted

func (g *ProcessGroup[I, O]) Aborted() bool

func (*ProcessGroup[I, O]) Close

func (g *ProcessGroup[I, O]) Close()

func (*ProcessGroup[I, O]) Error

func (g *ProcessGroup[I, O]) Error() error

func (*ProcessGroup[I, O]) FinishedInput

func (g *ProcessGroup[I, O]) FinishedInput()

Jump to

Keyboard shortcuts

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