Documentation ¶
Index ¶
- func AddMissingValues(target interface{}, source interface{}, ignoredFields ...string)
- func Assert(cond bool, i interface{})
- func AssertNoError(err error)
- func CheckFieldsAreInRange(obj interface{}, min, max float64, fieldNames ...string) (err error)
- func CheckFieldsAreSet(obj interface{}, fieldNames ...string) (err error)
- func Contains(list []string, element string) (result bool)
- func CopyFloat(in *float64) (out *float64)
- func CopyString(in *string) (out *string)
- func ExitOnError(err error, errMsg string, v ...interface{})
- func ExitWithMessage(errMsg string, v ...interface{})
- func GenericFieldsCheck(obj interface{}, isOk func(interface{}) bool, fieldNames ...string) (err error)
- func GetExecutableDir() (dirName string)
- func GetTempDir() (dirName string)
- func HasWhitespace(s string) bool
- func InformOnError(err error, errMsg string, v ...interface{})
- func IsDir(dirname string) (exists bool, err error)
- func IsExported(val reflect.Value) bool
- func IsFile(filename string) (exists bool, err error)
- func IsSet(val interface{}) (result bool)
- func IsTestEnvironment() bool
- func OpenWithDefaultViewer(file string) (err error)
- func QuoteStringIfRequired(s string) string
- func ReadFileToLines(filename string) (lines []string, err error)
- func SetIsTestEnvironment(isTestEnv bool)
- func SortCoords(c1, c2 float64) (float64, float64)
- func SplitAndTrim(input, sep string) (result []string)
- func ToCommaSeparatedString(input []string) (result string)
- func UnquoteStringIfRequired(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMissingValues ¶
func AddMissingValues(target interface{}, source interface{}, ignoredFields ...string)
AddMissingValues iterates over the exported fields of the source object. For each such fields it checks whether the target object contains a field with the same name. If that is the case and if the target field does not yet have a value set, then the value from the source object is copied over.
func Assert ¶
func Assert(cond bool, i interface{})
Assert will throw a panic if condition is false. The additional parameter is provided to panic() as argument.
func AssertNoError ¶
func AssertNoError(err error)
AssertNoError is a cheap function to check for err==nil and panics if condition is not met
func CheckFieldsAreInRange ¶
CheckFieldsAreInRange checks that all provided struct fields are within a given range.
func CheckFieldsAreSet ¶
CheckFieldsAreSet checks whether all provided struct fields have a non-zero value.
func CopyString ¶
CopyString creates a copy of a referenced string and returns the result as pointer.
func ExitOnError ¶
ExitOnError exits the program with rc=1 if err!=nil. The following Message and all additional arguments will be passed to fmt.Printf()
func ExitWithMessage ¶
func ExitWithMessage(errMsg string, v ...interface{})
ExitWithMessage prints out a message on StdErr and then exits the program with rc=1
func GenericFieldsCheck ¶
func GenericFieldsCheck(obj interface{}, isOk func(interface{}) bool, fieldNames ...string) (err error)
GenericFieldsCheck provides a generic way to check multiple fields of a struct at once.
func GetExecutableDir ¶
func GetExecutableDir() (dirName string)
GetExecutableDir returns the dir in which the binary of this program is located
func GetTempDir ¶
func GetTempDir() (dirName string)
GetTempDir returns the location of a temporary directory in which files can be stored. The caller needs to ensure that the directory is deleted afterwards.
func HasWhitespace ¶
HasWhitespace checks if a string includes at least one whitespace character
func InformOnError ¶
InformOnError provides an error message on stdErr if an error occurs, but continues with the program
func IsExported ¶
IsExported takes a reflection value and checks whether that is an exported field in a struct. Well, we cannot check here whether this is a struct field, but under the assumption that it was one, we can check whether it is exported then. Yay!
func IsSet ¶
func IsSet(val interface{}) (result bool)
IsSet checks whether the provided value is different from its zero value for element types and different from nil for pointer type.s
func IsTestEnvironment ¶
func IsTestEnvironment() bool
IsTestEnvironment should indicate whether the current run is a test run.
func OpenWithDefaultViewer ¶
OpenWithDefaultViewer opens the provided file with the default viewer registered in the system for this.
func QuoteStringIfRequired ¶
QuoteStringIfRequired takes a string as input. If the string contains whitespace, then it is returned enclosed by quotation marks, else it is returned as-is
func ReadFileToLines ¶
ReadFileToLines reads in the given file and returns the content as string array of lines
func SetIsTestEnvironment ¶
func SetIsTestEnvironment(isTestEnv bool)
SetIsTestEnvironment sets a flag that indicates that we are currently in a test environment.
func SortCoords ¶
SortCoords takes two coordinates and returns them ordered from large to small
func SplitAndTrim ¶
SplitAndTrim splits the string up at the provided separator and them trims each substring.
func ToCommaSeparatedString ¶
ToCommaSeparatedString takes a list of input values and returns them as single string with all values separated by commas.
func UnquoteStringIfRequired ¶
UnquoteStringIfRequired takes a string as input. If the string is enclosed in quotation marks, then these are removed in the returned string
Types ¶
This section is empty.