utils

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "1.0.4"

Version of rivendell

Functions

func Ask

func Ask(question string, possibleValue ...string)

Ask .

func Error

func Error(err error)

Error .

func ExecuteTemplate

func ExecuteTemplate(templateFile string, variables map[string]string) ([]byte, error)

ExecuteTemplate .

func ExpandEnv

func ExpandEnv(s string) string

ExpandEnv replaces $(var) with environment variable value

func ExpectAnswer

func ExpectAnswer(expected string) (bool, error)

ExpectAnswer .

func Fatal

func Fatal(err error)

Fatal .

func GlobFiles

func GlobFiles(includePatterns, excludePatterns []string) ([]string, error)

GlobFiles returns list of files based on inclusion and exclusion pattern

func Info

func Info(msg string, args ...interface{})

Info .

func Info2

func Info2(msg string, args ...interface{})

Info2 .

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

MergeMaps merges multiple maps into one

func NilArrayToEmpty

func NilArrayToEmpty(a []string) []string

NilArrayToEmpty converts a nil array to empty array if possible

func PrependPaths

func PrependPaths(prefix string, paths []string) []string

PrependPaths prepends a prefix to an array of paths

func StringArrayMap

func StringArrayMap(a []string, f func(string) string) []string

StringArrayMap .

func Success

func Success(msg string, args ...interface{})

Success .

func TestEnable

func TestEnable() bool

TestEnable .

func Warn

func Warn(msg string, args ...interface{})

Warn .

Types

type Command

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

Command only Unix is supported

func NewCommand

func NewCommand(name string, args ...string) *Command

NewCommand .

func (*Command) CombineOutput

func (cmd *Command) CombineOutput() *Command

CombineOutput to command stdout buffer

func (*Command) RedirectToStandard

func (cmd *Command) RedirectToStandard()

RedirectToStandard os.Stdout and os.Stderr

func (*Command) Run

func (cmd *Command) Run() (*CommandStatus, error)

Run the command. If the command exit non-zero, the returned error is still nil.

func (*Command) SetStderr

func (cmd *Command) SetStderr(w io.Writer)

SetStderr .

func (*Command) SetStdin

func (cmd *Command) SetStdin(content []byte)

SetStdin .

func (*Command) SetStdinReader

func (cmd *Command) SetStdinReader(r io.Reader)

SetStdinReader .

func (*Command) SetStdout

func (cmd *Command) SetStdout(w io.Writer)

SetStdout .

func (*Command) SilenceOutput

func (cmd *Command) SilenceOutput()

SilenceOutput .

type CommandStatus

type CommandStatus struct {
	ExitCode    int
	Stdout      io.Reader
	Stderr      io.Reader
	ElaspedTime time.Duration
}

CommandStatus .

func ExecuteCommand

func ExecuteCommand(command string, args ...string) (*CommandStatus, error)

ExecuteCommand and redirect output to standard output/standard error

func ExecuteCommandSilently

func ExecuteCommandSilently(command string, args ...string) (*CommandStatus, error)

ExecuteCommandSilently .

type StringSet

type StringSet map[string]struct{}

StringSet .

func NewStringSet

func NewStringSet(values ...string) StringSet

NewStringSet .

func (StringSet) Add

func (s StringSet) Add(values ...string)

Add new values to string set

func (StringSet) Exists

func (s StringSet) Exists(value string) bool

Exists checks a value appears in the set or not

func (StringSet) First

func (s StringSet) First() string

First returns first element from the set

func (StringSet) Join

func (s StringSet) Join(another StringSet) StringSet

Join .

func (StringSet) Remove

func (s StringSet) Remove(values ...string)

Remove values from string set

func (StringSet) ToSlice

func (s StringSet) ToSlice() []string

ToSlice converts the string set to a slice

Jump to

Keyboard shortcuts

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