utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResetText         Color = "\x1b[0000m"
	BrightText              = "\x1b[0001m"
	RedText                 = "\x1b[0031m"
	GreenText               = "\x1b[0032m"
	YellowText              = "\x1b[0033m"
	BlueText                = "\x1b[0034m"
	MagentaText             = "\x1b[0035m"
	CyanText                = "\x1b[0036m"
	WhiteText               = "\x1b[0037m"
	DefaultText             = "\x1b[0039m"
	BrightRedText           = "\x1b[1;31m"
	BrightGreenText         = "\x1b[1;32m"
	BrightYellowText        = "\x1b[1;33m"
	BrightBlueText          = "\x1b[1;34m"
	BrightMagentaText       = "\x1b[1;35m"
	BrightCyanText          = "\x1b[1;36m"
	BrightWhiteText         = "\x1b[1;37m"
)

Color codes interpretted by the terminal NOTE: all codes must be of the same length or they will throw off the field alignment of tabwriter

Variables

View Source
var SkipColor bool

Functions

func ColorForState

func ColorForState(state string) string

func Paint

func Paint(color Color, value string) string

func PaintForState

func PaintForState(text, state string) string

func ShortNodeName added in v1.1.1

func ShortNodeName(s string) string

ShortNodeName helps reducing the node name when it is the default value (node hostname) It only keeps the top-level domain

func SliceContains

func SliceContains(s []string, str string) bool

func SliceMergeDeduplicate

func SliceMergeDeduplicate(s, s2 []string) []string

func StringsReplaceReversed

func StringsReplaceReversed(s, old, new string, n int) string

StringsReplaceReversed is similar to strings.Replace, but replacing the right-most elements instead of left-most

func UUIDToShortUUID

func UUIDToShortUUID(uuid string) string

Types

type Color

type Color string

Color is given its own type for safe function signatures

func (*Color) String

func (c *Color) String() string

Color implements the Stringer interface for interoperability with string

Jump to

Keyboard shortcuts

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