common

package
v0.14.13 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package common contains common utility functions.

Index

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 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

func PrettyByteSize(bf float64) string

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.

Jump to

Keyboard shortcuts

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