util

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: Apache-2.0 Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

Functions

func BackupDirectory added in v1.3.3

func BackupDirectory(sourceDir string, backupDir string) (bool, error)

BackupDirectory checks for existence of the $sourceDir and backs it up to backupDir

func Base64String

func Base64String(path string) (string, error)

Base64String read file and return base64 string

func Contains added in v1.4.0

func Contains(find string, list []string) bool

func CreateDir

func CreateDir(dir string, perm os.FileMode) error

CreateDir check if directory exists and create it

func GetIPFromCIDR

func GetIPFromCIDR(cidr string, n int) (net.IP, error)

GetIPFromCIDR Naive implementation, but works

func Intersects added in v1.3.0

func Intersects(first, second []string) bool

Intersects returns true if any element from the first slice is in the second slice

func PrettyPrint

func PrettyPrint(out io.Writer, msg string, a ...interface{})

PrettyPrint no type will be displayed, used for just single line printing

func PrettyPrintErr

func PrettyPrintErr(out io.Writer, msg string, a ...interface{})

PrettyPrintErr [ERROR](Red) with formatted string

func PrettyPrintErrorIgnored

func PrettyPrintErrorIgnored(out io.Writer, msg string, a ...interface{})

PrettyPrintErrorIgnored [ERROR IGNORED](Red) with formatted string

func PrettyPrintOk

func PrettyPrintOk(out io.Writer, msg string, a ...interface{})

PrettyPrintOk [OK](Green) with formatted string

func PrettyPrintSkipped

func PrettyPrintSkipped(out io.Writer, msg string, a ...interface{})

PrettyPrintSkipped [SKIPPED](blue) with formatted string

func PrettyPrintUnreachable

func PrettyPrintUnreachable(out io.Writer, msg string, a ...interface{})

PrettyPrintUnreachable [UNREACHABLE](Red) with formatted string

func PrettyPrintWarn

func PrettyPrintWarn(out io.Writer, msg string, a ...interface{})

PrettyPrintWarn [WARNING](Orange) with formatted string

func PrintColor

func PrintColor(out io.Writer, clr *color.Color, msg string, a ...interface{})

PrintColor prints text in color

func PrintError

func PrintError(out io.Writer)

PrintError print whole message in error(Red) format

func PrintHeader

func PrintHeader(out io.Writer, msg string, padding byte)

PrintHeader will print header with predifined width

func PrintOk

func PrintOk(out io.Writer)

PrintOk print whole message in green(Red) format

func PrintOkln

func PrintOkln(out io.Writer)

PrintOkln print whole message in green(Red) format

func PrintSkipped

func PrintSkipped(out io.Writer)

PrintSkipped print whole message in green(Red) format

func PrintTable added in v1.3.0

func PrintTable(out io.Writer, msgMap map[string][]string)

func PrintValidationErrors added in v1.2.0

func PrintValidationErrors(out io.Writer, errors []error)

PrintValidationErrors loops through the errors

func PrintWarn

func PrintWarn(out io.Writer)

PrintWarn print whole message in warn(Orange) format

func PromptForInt

func PromptForInt(in io.Reader, out io.Writer, prompt string, defaultValue int) (int, error)

PromptForInt read command line input

func PromptForString added in v1.4.0

func PromptForString(in io.Reader, out io.Writer, prompt string, defaultValue string, choices []string) (string, error)

func Subset added in v1.2.0

func Subset(first, second []string) bool

Subset returns true if the first slice is completely contained in the second slice

Types

type LineReader added in v1.4.1

type LineReader struct {
	// contains filtered or unexported fields
}

LineReader provides a way to read lines of text with arbitrary length. The line is buffered in memory.

func NewLineReader added in v1.4.1

func NewLineReader(r io.Reader, bufSizeBytes int) LineReader

NewLineReader returns a LineReader to read from r. It wraps the reader with a buffered reader that has a buffer of size bufSizeBytes.

func (LineReader) Read added in v1.4.1

func (lr LineReader) Read() ([]byte, error)

Read an entire line from the reader.

Jump to

Keyboard shortcuts

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