utils

package
v0.0.0-...-4b634d0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BashCompletion

func BashCompletion(cmd *cobra.Command, flags *pflag.FlagSet, flag string, fname, fbody string) error

BashCompletion annotates the flag with completion function and registers the completion function in the root command if it hasn't been added already.

func NewBackgroundSpinner

func NewBackgroundSpinner(description string, refresh time.Duration) context.CancelFunc

NewBackgroundSpinner creates a new spinner which runs in background refreshing its output on a constant rate. The spinner is prefixed with the provided description. Returns a function which cancels the spinner. The default value for refresh is used if provided refresh is less than or equal to zero.

func RandomHex

func RandomHex(n int) (string, error)

RandomHex generates a random hex string of specified length.

func WithDefaultPort

func WithDefaultPort(hostport string, port int) string

WithDefaultPort adds a default port if no port is present.

Types

type NamedRegex

type NamedRegex struct {
	*regexp.Regexp
}

NamedRegex is a regex which supports named capture groups.

func MustCompile

func MustCompile(s string) NamedRegex

MustCompile compiles a string to a named regexp.

func (*NamedRegex) FindStringSubmatchMap

func (r *NamedRegex) FindStringSubmatchMap(s string) map[string]string

FindStringSubmatchMap returns a map of named capture groups.

Jump to

Keyboard shortcuts

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