util

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllUnique added in v0.1.2

func AllUnique[T comparable](sl []T) bool

AllUnique returns true if all elements in the given slice are unique.

func Contains

func Contains[T comparable](sl []T, item T) bool

Contains returns true if the given slice contains the given item.

func DecodeOptions

func DecodeOptions(in io.ReadCloser, formatHint string, out any) error

DecodeOptions will attempt to decode the given reader into the given object. The formatHint is used to select the format of the document. If the formatHint is empty, the format is guessed from the document. The document is first treated as a go-template with some custom functions. This allows us to use environment variables and file contents in the config.

func Exec

func Exec(ctx context.Context, command string, args ...string) error

Exec executes a command with context.

func ExecOutput

func ExecOutput(ctx context.Context, command string, args ...string) ([]byte, error)

ExecOutput executes a command with context and returns the output.

func Pointer

func Pointer[T any](t T) *T

Pointer returns a pointer to the given value.

func PrettyByteSize added in v0.1.2

func PrettyByteSize(bf float64) string

PrettyByteSize returns a human-readable string of the given byte size.

func UpsertSlice added in v0.6.0

func UpsertSlice[T comparable](sl []T, item T) []T

UpsertSlice with insert the given item into a slice if it does not exist, otherwise it will update the existing item and return the updated slice.

Types

This section is empty.

Directories

Path Synopsis
Package meshutil contains helpers for computing networking information from the mesh.
Package meshutil contains helpers for computing networking information from the mesh.
package netutil provides common utility functions for networking.
package netutil provides common utility functions for networking.

Jump to

Keyboard shortcuts

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