util

package
v1.13.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(network, host string) string

Address constructs a URL from the given network and hostname.

func AddressUnspecifiedLess added in v1.8.0

func AddressUnspecifiedLess(a, b net.Addr) bool

AddressUnspecifiedLess is a comparator function preferring least specific network address (most widely listening, namely preferring 0.0.0.0 over some IP), if both IPs are equal, it prefers the less restrictive network (prefers tcp over tcp4)

func CallWithContext added in v1.4.1

func CallWithContext(ctx context.Context, fn func() error) error

func CopyMatchingTag added in v0.14.42

func CopyMatchingTag(from interface{}, to interface{}, tag string, shouldCopy func(value string) bool)

CopyMatchingTag copies fields tagged tag:"value" from "from" struct onto "to" struct.

func FillNil added in v1.8.0

func FillNil(data interface{})

func FillNilExceptDeprecated added in v1.12.1

func FillNilExceptDeprecated(data interface{})

func FillNilSlices

func FillNilSlices(data interface{}) error

FillNilSlices sets default value on slices that are still nil.

func NiceDurationString added in v1.8.0

func NiceDurationString(d time.Duration) string

func NoRestartErr added in v1.12.1

func NoRestartErr(err error) error

NoRestartErr wraps the given error err (which may be nil) to make sure that `errors.Is(err, suture.ErrDoNotRestart) == true`.

func OnDone added in v1.12.1

func OnDone(ctx context.Context, fn func())

OnDone calls fn when ctx is cancelled.

func SetDefaults

func SetDefaults(data interface{})

SetDefaults sets default values on a struct, based on the default annotation.

func UniqueTrimmedStrings added in v1.2.0

func UniqueTrimmedStrings(ss []string) []string

UniqueTrimmedStrings returns a list on unique strings, trimming at the same time.

Types

type ExitStatus added in v1.12.1

type ExitStatus int
const (
	ExitSuccess            ExitStatus = 0
	ExitError              ExitStatus = 1
	ExitNoUpgradeAvailable ExitStatus = 2
	ExitRestart            ExitStatus = 3
	ExitUpgrade            ExitStatus = 4
)

func (ExitStatus) AsInt added in v1.12.1

func (s ExitStatus) AsInt() int

type FatalErr added in v1.12.1

type FatalErr struct {
	Err    error
	Status ExitStatus
}

func (*FatalErr) Error added in v1.12.1

func (e *FatalErr) Error() string

func (*FatalErr) Is added in v1.12.1

func (e *FatalErr) Is(target error) bool

func (*FatalErr) Unwrap added in v1.12.1

func (e *FatalErr) Unwrap() error

Jump to

Keyboard shortcuts

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