utils

package
v0.26.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context, url string, headers map[string]string, timeout time.Duration) (string, error)

Get is a helper function to make a GET request to the specified URL and return the response body as a string.

func GetClusterDomain added in v0.26.0

func GetClusterDomain() (string, error)

GetClusterDomain retrieves cluster domain of Kubernetes cluster we are installed on. It can be retrieved by looking up CNAME of kubernetes.default.svc and extracting its suffix.

func IsHTTPUrl

func IsHTTPUrl(url string) bool

IsHTTPUrl returns true if the given string is an HTTP(S) URL.

func Mod added in v0.19.0

func Mod(a, b int) int

Mod is a normal modulo operation which does not produce negative values.

func RemoveFromSlice added in v0.26.0

func RemoveFromSlice(a []string, x string) []string

RemoveFromSlice removes x from a and returns the new slice.

func Shutdown added in v0.19.0

func Shutdown(shutdowner fx.Shutdowner)

Shutdown invokes fx.Shutdowner and logs error if any.

func SliceContains

func SliceContains(a []string, x string) bool

SliceContains tells whether a contains x.

func SliceFind

func SliceFind(a []string, x string) int

SliceFind returns the smallest index i at which x == a[i], or len(a) if there is no such index.

func SliceToMap added in v0.1.3

func SliceToMap(a []string) map[string]bool

SliceToMap converts a slice of string to a map[string]bool.

Types

type GoLeakDetector

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

GoLeakDetector holds options for the goleak detector.

func NewGoLeakDetector

func NewGoLeakDetector() *GoLeakDetector

NewGoLeakDetector creates a new GoLeakDetector with goleakOptions.

func (*GoLeakDetector) AddIgnoreTopFunctions

func (l *GoLeakDetector) AddIgnoreTopFunctions(fs ...string)

AddIgnoreTopFunctions adds functions to ignore in the leak detector.

func (*GoLeakDetector) FindLeaks

func (l *GoLeakDetector) FindLeaks() error

FindLeaks finds memory leaks in the current process.

Jump to

Keyboard shortcuts

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