Documentation ¶
Overview ¶
Package common contains common utility functions.
Index ¶
- func AllUnique[T comparable](sl []T) bool
- func Exec(ctx context.Context, command string, args ...string) error
- func ExecOutput(ctx context.Context, command string, args ...string) ([]byte, error)
- func Pointer[T any](t T) *T
- func PrettyByteSize(bf float64) string
- func UpsertSlice[T comparable](sl []T, item T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllUnique ¶
func AllUnique[T comparable](sl []T) bool
AllUnique returns true if all elements in the given slice are unique.
func ExecOutput ¶
ExecOutput executes a command with context and returns the output.
func PrettyByteSize ¶
PrettyByteSize returns a human-readable string of the given byte size.
func UpsertSlice ¶
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.
Click to show internal directories.
Click to hide internal directories.