utils

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package utils provides general utility methods. The '*Ptr' functions were borrowed/inspired by the kubernetes go-client.

Index

Constants

View Source
const DirPermissions os.FileMode = 0750

DirPermissions is the default permission mode for directories created by the SDK. 0750 = owner: rwx, group: r-x, others: --- (no access).

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to a bool.

func CallerFileLine

func CallerFileLine() (string, int)

CallerFileLine returns file name and line of invoker. Similar to CallerName(1), but with file and line returned.

func CallerName

func CallerName(up int) string

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

func CallerPath(up int) string

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

func FindString(slice []string, val string) (int, bool)

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 GetExecutableName

func GetExecutableName() string

GetExecutableName returns name of executable without file extension.

func Int64Ptr

func Int64Ptr(i int64) *int64

Int64Ptr returns a pointer to an int64.

func JSON

func JSON(data interface{}) []byte

JSON marshals a struct into JSON with indentation.

func ReformatError

func ReformatError(e string, v ...interface{}) error

ReformatError prefixes the error string ready for logging and/or output.

func ReplaceBytesMultipleValues

func ReplaceBytesMultipleValues(b []byte, replacer *strings.Replacer) []byte

ReplaceBytesMultipleValues replaces multiple substrings with a new value for a given string in bytes.

func ReplaceBytesValue

func ReplaceBytesValue(b []byte, old string, new string) []byte

ReplaceBytesValue replaces a substring with a new value for a given string in bytes.

func StringPtr

func StringPtr(s string) *string

StringPtr returns a pointer to the passed string.

func StringSliceContains

func StringSliceContains(arr []string, val string) bool

StringSliceContains checks if a string value exists in a string slice.

func WriteAllowed

func WriteAllowed(path string) error

WriteAllowed determines whether a given filepath can be written to.

Types

This section is empty.

Jump to

Keyboard shortcuts

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