util

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MPL-2.0 Imports: 8 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 AsService added in v1.2.1

func AsService(fn func(ctx context.Context), creator string) suture.Service

AsService wraps the given function to implement suture.Service by calling that function on serve and closing the passed channel when Stop is called.

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 FillNilSlices

func FillNilSlices(data interface{}) error

FillNilSlices sets default value on slices that are still nil.

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 ServiceWithError added in v1.2.1

type ServiceWithError interface {
	suture.Service
	fmt.Stringer
	Error() error
	SetError(error)
}

func AsServiceWithError added in v1.2.1

func AsServiceWithError(fn func(ctx context.Context) error, creator string) ServiceWithError

AsServiceWithError does the same as AsService, except that it keeps track of an error returned by the given function.

Jump to

Keyboard shortcuts

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