goutils

package
v0.0.0-...-2b706d3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLogWhenValExist

func AddLogWhenValExist(title string, val string) string

AddLogWhenValExist returns a formatted string if value exists

func AppendStringIfNotMember

func AppendStringIfNotMember(list []string, item string) []string

AppendStringIfNotMember only appends if not already a member

func Contains

func Contains(listToCheck []string, toFind string, isCaseSensitive bool) bool

Contains returns true if a string can be found in a list of strings, false otherwise isCaseSensitive defines whether the string needs to match capitalization to return true case sensitivity based on Unicode case-folding, more general form of case-insensitivity

func Copy

func Copy(src, dst string) error

Copy copies a src file to a dst file where src and dst are regular files.

func CopyDirectory

func CopyDirectory(opts CopyDirectoryOpts) error

CopyDirectory recursively copies a src directory to a destination.

func CopySymLink(src, dst string) error

CopySymLink copies a symbolic link from src to dst.

func ExtractFirstJSONFromString

func ExtractFirstJSONFromString(s string) string

ExtractFirstJSONFromString returns the first bracket-balanced json-looking substring in a string It returns the empty string if the string has no json-looking substring or does not have a json-looking substring with balanced brackets

	Sometimes, when we run hooks, they return the expected json object but with some other
	warning messages that we don't need.  This causes errors when unmarshalling.  This function
 helps us extract exactly what we need and ignore the rest.

func HashString

func HashString(s string) (string, error)

HashString will compute a short sha1 identity for a text blob

func JSONMarshalUnescaped

func JSONMarshalUnescaped(v interface{}) (string, error)

JSONMarshalUnescaped converts a struct into a JSON encoding without escaping characters

func JSONMarshalUnescapedIndent

func JSONMarshalUnescapedIndent(v interface{}) (string, error)

JSONMarshalUnescapedIndent converts a struct into an easily readable JSON encoding without escaping characters

func JSONUnmarshal

func JSONUnmarshal(data []byte, v interface{}) error

JSONUnmarshal is a wrapper for json.Unmarshal which parses the JSON-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, json.Unmarshal returns an InvalidUnmarshalError which gets converted to a slackerror that is more human readable.

func MapToStringSlice

func MapToStringSlice(args map[string]string, prefix string) []string

MapToStringSlice converts a map[string]string to a slice of strings with elements key="value" from the map with an optional prefix

func MapToStringSliceKeys

func MapToStringSliceKeys(args map[string]struct{}) []string

MapToStringSliceKeys takes a map[string]interface{} and returns its keys as a slice of strings

func MergeJSON

func MergeJSON(defaultJSON string, customJSON string, config interface{}) error

MergeJSON will merge customJSON into defaultJSON and unmarshal the results to config. When JSON arguments are an empty string, it will default the arg to "{}"

func RedactPII

func RedactPII(s string) string

RedactPII will replace all occurrences in a string that match any of the expressions in a regex list

func ShouldIgnore

func ShouldIgnore(val string, list []string, ignoreFunc func(string) bool) bool

ShouldIgnore returns true if a file or directory is in the exclusion list or ignore function

func ToHTTPS

func ToHTTPS(urlAddr string) string

ToHTTPS returns url with https protocol

func UpperCaseTrimAll

func UpperCaseTrimAll(namedEntities string) string

UpperCaseTrimAll returns a formatted named_entites for trigger ACLs

Types

type CopyDirectoryOpts

type CopyDirectoryOpts struct {
	Src                   string
	Dst                   string
	IgnoreFiles           []string
	IgnoreDirectories     []string
	IgnoreFunc            func(string) bool
	RelativeParentDirPath string
}

Jump to

Keyboard shortcuts

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