common

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoIfFalse added in v0.3.0

func DoIfFalse(assertToBeTrue *bool, otherwise func())

func FormatVersion

func FormatVersion(v Version, format VersionFormat) string

func IgnoreCloseError

func IgnoreCloseError(when io.Closer)

func IgnoreCloseErrorIfFalse added in v0.3.0

func IgnoreCloseErrorIfFalse(assertToBeTrue *bool, otherwise io.Closer)

func IgnoreError

func IgnoreError(when func() error)

func IgnoreErrorIfFalse added in v0.3.0

func IgnoreErrorIfFalse(assertToBeTrue *bool, otherwise func() error)

func JoinSeq added in v0.3.0

func JoinSeq[T any](seqs ...iter.Seq[T]) iter.Seq[T]

func JoinSeq2 added in v0.3.0

func JoinSeq2[K any, V any](seqs ...iter.Seq2[K, V]) iter.Seq2[K, V]

func KeepCloseError

func KeepCloseError(target *error, when io.Closer)

func KeepError

func KeepError(target *error, when func() error)

func MapSlice

func MapSlice[I any, O any](in []I, mapper func(I) O) []O

func MapSliceErr

func MapSliceErr[I any, O any](in []I, mapper func(I) (O, error)) ([]O, error)

func Must

func Must(v error, msgAndArgs ...any)

func MustNotNil

func MustNotNil(v any, msgAndArgs ...any)

func P

func P[T any](a T) *T

func Seq2ErrOf added in v0.3.0

func Seq2ErrOf[T any](ts ...T) iter.Seq2[T, error]

func Seq2Of added in v0.3.0

func Seq2Of[K any, V any](kvs ...KV[K, V]) iter.Seq2[K, V]

func SeqOf added in v0.3.0

func SeqOf[T any](ts ...T) iter.Seq[T]

func SingleSeq2Of added in v0.3.0

func SingleSeq2Of[K any, V any](k K, v V) iter.Seq2[K, V]

func SingleSeqOf added in v0.3.0

func SingleSeqOf[T any](t T) iter.Seq[T]

func ToDebugString

func ToDebugString(formatted bool, what any) string

func VersionToMap added in v0.2.0

func VersionToMap(v Version) map[string]any

Types

type Duration

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

func DurationOf

func DurationOf(native time.Duration) Duration

func MustNewDuration

func MustNewDuration(plain string) Duration

func NewDuration

func NewDuration(plain string) (Duration, error)

func (Duration) IsEqualTo

func (this Duration) IsEqualTo(other any) bool

func (Duration) IsZero

func (this Duration) IsZero() bool

func (Duration) MarshalText

func (this Duration) MarshalText() (text []byte, err error)

func (*Duration) Native

func (this *Duration) Native() time.Duration

func (*Duration) Set

func (this *Duration) Set(text string) error

func (*Duration) SetNative

func (this *Duration) SetNative(v time.Duration)

func (Duration) String

func (this Duration) String() string

func (*Duration) UnmarshalText

func (this *Duration) UnmarshalText(text []byte) error

type FileMode

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

func MustNewFileMode

func MustNewFileMode(plain string) FileMode

func NewFileMode

func NewFileMode(plain string) (FileMode, error)

func (FileMode) Get

func (this FileMode) Get() os.FileMode

func (FileMode) IsEqualTo

func (this FileMode) IsEqualTo(other any) bool

func (FileMode) IsZero

func (this FileMode) IsZero() bool

func (FileMode) MarshalText

func (this FileMode) MarshalText() (text []byte, err error)

func (*FileMode) Set

func (this *FileMode) Set(text string) error

func (FileMode) String

func (this FileMode) String() string

func (*FileMode) UnmarshalText

func (this *FileMode) UnmarshalText(text []byte) error

type KV added in v0.3.0

type KV[K any, V any] struct {
	K K
	V V
}

type Regexp

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

func MustNewRegexp

func MustNewRegexp(plain string) Regexp

func NewRegexp

func NewRegexp(plain string) (Regexp, error)

func (Regexp) IsEqualTo

func (this Regexp) IsEqualTo(other any) bool

func (Regexp) IsZero

func (this Regexp) IsZero() bool

func (Regexp) MarshalText

func (this Regexp) MarshalText() (text []byte, err error)

func (*Regexp) MatchString

func (this *Regexp) MatchString(s string) bool

func (*Regexp) Set

func (this *Regexp) Set(text string) error

func (Regexp) String

func (this Regexp) String() string

func (*Regexp) UnmarshalText

func (this *Regexp) UnmarshalText(text []byte) error

type Remote

type Remote interface {
	User() string
	Host() net.Host
	String() string
}

type StructuredKey

type StructuredKey []string

func StructuredKeyOf

func StructuredKeyOf(args ...string) StructuredKey

func (StructuredKey) Child

func (this StructuredKey) Child(key string) StructuredKey

func (StructuredKey) Index

func (this StructuredKey) Index(i int) StructuredKey

func (StructuredKey) String

func (this StructuredKey) String() string

type Version

type Version interface {
	Title() string
	Version() string
	Revision() string
	Edition() VersionEdition
	BuildAt() time.Time
	Vendor() string
	GoVersion() string
	Platform() string
	Features() VersionFeatures
}

type VersionEdition

type VersionEdition uint8
const (
	VersionEditionUnknown VersionEdition = iota
	VersionEditionGeneric
	VersionEditionExtended
)

func (*VersionEdition) Set

func (this *VersionEdition) Set(plain string) error

func (VersionEdition) String

func (this VersionEdition) String() string

type VersionFeature added in v0.2.0

type VersionFeature interface {
	Name() string
}

type VersionFeatureCategory added in v0.2.0

type VersionFeatureCategory interface {
	Name() string
	ForEach(func(VersionFeature))
}

type VersionFeatures added in v0.2.0

type VersionFeatures interface {
	ForEach(func(VersionFeatureCategory))
}

type VersionFormat

type VersionFormat uint8
const (
	VersionFormatShort VersionFormat = iota
	VersionFormatLong
)

Jump to

Keyboard shortcuts

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