Documentation ¶
Overview ¶
Package utils :: aws.go - extended AWS SDK functions
Package utils :: bit.go
Package utils :: config.go
Get project settings from os env or specified config.yaml ¶
Package utils :: conv.go - extended string formatter functions
Package utils :: env.go - extended os env functions
Package utils :: fmt.go - extended fmt functions
Package utils :: interface.go
Package utils :: io.go
Package utils :: logging.go
Package utils :: pair.go
Package utils :: string.go
Package utils :: testing.go
Package utils :: utf.go
Index ¶
- Variables
- func BitAllOne() int64
- func BitCheck(x int64, n uint8) bool
- func BitClear(x int64, n uint8) int64
- func BitCountOne(x int64) int
- func BitCountOneUint64(x uint64) int
- func BitIntersection(a, b int64) int64
- func BitInverse(x int64) int64
- func BitIsPowerOf2(number int64) bool
- func BitIsPowerOf4(number int64) bool
- func BitNegativeInt(x int64) int64
- func BitSet(x int64, n uint8) int64
- func BitString(x uint64, key, delimiter string) string
- func BitSubstraction(a, b int64) int64
- func BitSumInt(x, y int) int
- func BitSumInt64(x, y int64) int64
- func BitUnion(a, b int64) int64
- func CheckEnvBoolean(name string, ignoreCase bool) bool
- func Debug(format string, v ...interface{})
- func DebugOff()
- func DebugOn()
- func DebugReset()
- func Debugln(a ...interface{})
- func DecryptKeyTextByKMS(key, text string) string
- func Flatten(prefix string, value interface{}, kvmap map[string]string)
- func FlattenConfig(file string) map[string]string
- func FmtComma(number string) string
- func GetEnvron() map[string]string
- func GetGraphemeCount(str string) int
- func GetGraphemeCountInString(str string) int
- func GetSliceAtIndex(input string, index int) string
- func GetTernary(condition bool, a interface{}, b interface{}) interface{}
- func GetTestName(t *testing.T) string
- func GetTestNameByCaller() string
- func HasEnv(name string, ignoreCase bool) bool
- func IsDigitOrLetter(char rune) bool
- func Readlines(r *bufio.Reader) ([]string, error)
- func ReplaceProxyURL(url, prefix, proxyURL string) string
- func ShiftSlice(input string, shift int) string
- func StringIn(stringInput string, stringList []string, options ...bool) bool
- func ToBinaryString(x uint64, delimiter string) string
- func ToCamel(in string, keepAllCaps ...bool) string
- func ToHexString(x uint64, delimiter string) string
- func ToJSON(t interface{}) string
- func ToSnake(in string) string
- type Config
- func (c Config) Get(key string, defaultValues ...string) string
- func (c Config) GetBool(key string, defaultValues ...bool) bool
- func (c Config) GetInt32(key string, defaultValues ...int32) int32
- func (c Config) GetInt64(key string, defaultValues ...int64) int64
- func (c Config) GetUint32(key string, defaultValues ...uint32) uint32
- func (c Config) GetUint64(key string, defaultValues ...uint64) uint64
- type ConfigParserFunc
- type ConfigReaderFunc
- type DecryptFunc
- type Env
- type KMSDecryptInterface
- type Pair
Constants ¶
This section is empty.
Variables ¶
var ( // BinaryString is an array of all 4-bit binary representation BinaryString = map[string][]string{ "b": { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111", }, "x": { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", }, } )
var DebugEnv = CheckEnvBoolean("DEBUG", true)
DebugEnv indicates DEBUG = 1|on|true in environment variable (ignoring case)
var DebugEnvStore = DebugEnv
DebugEnvStore keeps a backup of DebugEnv value
Functions ¶
func BitCountOne ¶
BitCountOne returns number of 1 in x (aka Hamming weight)
func BitCountOneUint64 ¶
BitCountOneUint64 returns number of 1 in x (aka Hamming weight)
func BitIntersection ¶
BitIntersection applies bitwise AND (&) operator on a and b (interaction)
func BitIsPowerOf2 ¶
BitIsPowerOf2 checks if the number is power of 2
func BitIsPowerOf4 ¶
BitIsPowerOf4 checks if the number is power of 4
func BitNegativeInt ¶
BitNegativeInt returns negative number of x (0 - x)
func BitSumInt64 ¶
BitSumInt64 calculates sum of two integers without using arithmetic operators
func CheckEnvBoolean ¶
CheckEnvBoolean checks if an environment variable is set to non-false/non-zero
func Debug ¶
func Debug(format string, v ...interface{})
Debug prints logging message if DEBUG is set
func Debugln ¶
func Debugln(a ...interface{})
Debugln prints logging message (with new line) if DEBUG is set
func DecryptKeyTextByKMS ¶
DecryptKeyTextByKMS checks possible encrypted KMS key/value and retruns decrypted text
func FlattenConfig ¶
FlattenConfig loads a config file (.yaml) to flattened key/value map
func GetGraphemeCountInString ¶
GetGraphemeCountInString function
func GetSliceAtIndex ¶
GetSliceAtIndex returns indexed one-byte slice, or empty string
func GetTernary ¶
func GetTernary(condition bool, a interface{}, b interface{}) interface{}
GetTernary returns a if condition is true; otherwise returns b
func GetTestName ¶
GetTestName returns the name of the test function from testing.T.
func GetTestNameByCaller ¶
func GetTestNameByCaller() string
GetTestNameByCaller returns the name of the test function from the call stack.
func IsDigitOrLetter ¶
IsDigitOrLetter checks if a unicode char is digit or letter
func Readlines ¶
Readlines returns lines (without the ending \n) from buffered reader, additionally returns error from buffered reader if there is any.
func ReplaceProxyURL ¶
ReplaceProxyURL searches prefix in url and replaces with proxyURL
func ShiftSlice ¶
ShiftSlice returns slice by shift index
func ToBinaryString ¶
ToBinaryString converts uint64 x to zero-padding binary representation
func ToHexString ¶
ToHexString converts uint64 x to zero-padding hexadecimal representation
func ToJSON ¶
func ToJSON(t interface{}) string
ToJSON function returns pretty-printed JSON for a struct.
func ToSnake ¶
ToSnake converts a string to snake case format with unicode support See also https://github.com/serenize/snaker/blob/master/snaker.go
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents a flattened settings per config file
func (Config) Get ¶
Get gets string value of the key in os.Environ() or Config.settings or using defaultValues[0] if provided; otherwise return ""
type ConfigParserFunc ¶
ConfigParserFunc is a generic parser function
type ConfigReaderFunc ¶
ConfigReaderFunc is a generic reader function
type DecryptFunc ¶
DecryptFunc is a generic decrypt function
type Env ¶
type Env map[string]interface{}
Env struct stores application-wide configuration
type KMSDecryptInterface ¶
type KMSDecryptInterface interface {
Decrypt(input *kms.DecryptInput) (*kms.DecryptOutput, error)
}
KMSDecryptInterface interface