Documentation
¶
Overview ¶
Package utils provides general utility methods. The '*Ptr' functions were borrowed/inspired by the kubernetes go-client.
Index ¶
- func AuditPlaceholders() (string, interface{}, error)
- func BoolPtr(b bool) *bool
- func BoxStaticFile(boxName string, path ...string) *packr.Box
- func CallerFileLine() (string, int)
- func CallerName(up int) string
- func CallerPath(up int) string
- func FindString(slice []string, val string) (int, bool)
- func Int64Ptr(i int64) *int64
- func RandomString(n int) string
- func ReadStaticFile(path ...string) ([]byte, error)
- func ReformatError(e string, v ...interface{}) error
- func ReplaceBytesValue(b []byte, old string, new string) []byte
- func StringPtr(s string) *string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuditPlaceholders ¶ added in v0.6.0
AuditPlaceholders creates empty objects to reduce code repetition when auditing probe steps
func BoxStaticFile ¶ added in v0.4.0
func CallerFileLine ¶ added in v0.4.0
CallerFileLine returns file name and line of invoker Similar to CallerName(1), but with file and line returned
func CallerName ¶ added in v0.4.0
CallerName retrieves the name of the function prior to the location it is called If using CallerName(0), the current function's name will be returned If using CallerName(1), the current function's parent name will be returned If using CallerName(2), the current function's parent's parent name will be returned
func CallerPath ¶ added in v0.4.0
CallerPath checks the goroutine's stack of function invocation and returns the following: For up=0, return full caller path for caller function For up=1, returns full caller path for caller of caller
func FindString ¶ added in v0.5.0
FindString searches a []string for a specific value. If found, returns the index of first occurrence, and True. If not found, returns -1 and False.
func RandomString ¶ added in v0.5.0
Generates a pseudo-random number of characters of length n
func ReadStaticFile ¶ added in v0.4.0
ReadStaticFile returns the bytes for a given static file If the static asset has not been added to packer, it adds it using full dir path as the box name. Path:
In most cases it will be ReadStaticFile(assetDir, fileName). It could also be used as ReadStaticFile(assetDir, subfolder, filename)
func ReformatError ¶ added in v0.3.0
ReformatError prefixes the error string ready for logging and/or output
func ReplaceBytesValue ¶ added in v0.4.0
ReplaceBytesValue replaces a substring with a new value for a given string in bytes
Types ¶
This section is empty.