util

package
v0.0.0-...-678a40c Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureLog

func ConfigureLog(filename string, toStdout bool, toFile bool)

ConfigureLog configures the logging.

func ContainsString

func ContainsString(haystack []string, needle string) bool

ContainsString returns true if a string slice contains the target string and false otherwise.

func FileExists

func FileExists(filename string) bool

FileExists returns whether or not a file exists.

func InterfaceIsZero

func InterfaceIsZero(targetInterface interface{}) bool

InterfaceIsZero determines whether or not an interface is its type's zero value.

func LoadFileIntoSlice

func LoadFileIntoSlice(filename string) ([]string, error)

LoadFileIntoSlice loads a file into a string slice.

func LoadXML

func LoadXML(filename string) mxj.Map

LoadXML loads a file into an xml map.

func RunSSHCommand

func RunSSHCommand(runSSHConfiguration RunSSHConfiguration, command string) string

RunSSHCommand runs an ssh command.

func SanitiseHTTPProxyURL

func SanitiseHTTPProxyURL(url string) string

SanitiseHTTPProxyURL strips the protocol (assumed to actually be http) and replaces it with http://, unless the string length without protocol is 0 in which case the empty string is returned.

func SanitisePath

func SanitisePath(path string) string

SanitisePath translates ~ into $HOME.

func ShellOut

func ShellOut(command string, args []string) (string, error)

ShellOut executes a command.

func UnsanitisePath

func UnsanitisePath(path string) string

UnsanitisePath translates $HOME into ~.

func ValueHasField

func ValueHasField(value reflect.Value, fieldName string) bool

ValueHasField returns whether a value has a given field.

func ValueHasMethod

func ValueHasMethod(value reflect.Value, methodName string) bool

ValueHasMethod returns whether a value has a given method.

func WriteSliceToFile

func WriteSliceToFile(filename string, contents []string)

WriteSliceToFile writes a string slice to a file.

func WriteToFile

func WriteToFile(filename string, content []byte)

WriteToFile writes a byte array to a file safely.

func WriteXML

func WriteXML(filename string, xmlMap mxj.Map)

WriteXML writes an xml map to a file.

Types

type RunSSHConfiguration

type RunSSHConfiguration struct {
	SSHHost string
	SSHPort string
	SSHUser string
	SSHKey  string
}

RunSSHConfiguration defines the configuration necessary to run an ssh command.

type TeeLogger

type TeeLogger struct {
	Filename string

	ToStdout bool
	ToFile   bool
	// contains filtered or unexported fields
}

TeeLogger acts like the GNU tee command - logs to stdout & file.

func (TeeLogger) Write

func (c TeeLogger) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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