utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadAll

func ReadAll(c ctx.C, r io.Reader, close func() error) ([]byte, error)

ReadAll() but honors the ctx.C cancel Note: it uses an internal go-routine, which will block on read If the close function is passed, it will be called when read is exhausted.

func Stack

func Stack(above, max int) []string

Types

type MapEntry

type MapEntry[V any] struct {
	Value V
	Found bool
}

type OrderedMap

type OrderedMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewOrderedMap

func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V]

func (*OrderedMap[K, V]) Delete

func (this *OrderedMap[K, V]) Delete(key K) MapEntry[V]

remove the pair and forget about the order

func (OrderedMap[K, V]) Get

func (this OrderedMap[K, V]) Get(key K) MapEntry[V]

func (OrderedMap[K, V]) Keys

func (this OrderedMap[K, V]) Keys() []K

func (OrderedMap[K, V]) Len

func (this OrderedMap[K, V]) Len() int

func (*OrderedMap[K, V]) Put

func (this *OrderedMap[K, V]) Put(key K, value V) MapEntry[V]

func (OrderedMap[K, V]) Range

func (this OrderedMap[K, V]) Range(f func(K, V) error) error

func (OrderedMap[K, V]) Values

func (this OrderedMap[K, V]) Values() []V

type Pair

type Pair[K any, V any] struct {
	Key   K
	Value V
}

type StackFrame

type StackFrame struct {
	File string
	Line int
	Func string
}

func Caller

func Caller(above int) StackFrame

Returns the StackFrame of the caller if above is zero.

func (StackFrame) AbsFile

func (this StackFrame) AbsFile() string

convert --trimpath like `aize.io/monorepo/...` to full path based on go.mod content

func (StackFrame) FileLine

func (this StackFrame) FileLine() string

func (StackFrame) FuncName

func (this StackFrame) FuncName() string

func (StackFrame) Pkg

func (this StackFrame) Pkg() string

func (StackFrame) ShortFunc

func (this StackFrame) ShortFunc() string

return only the package.FuncName

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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