Documentation ¶
Index ¶
- Variables
- func BytesConvertToUTF8(bytes []byte, charset string) ([]byte, error)
- func BytesMarshal(i interface{}) ([]byte, error)
- func BytesUnMarshal(data []byte, i interface{}) error
- func ExecCmdPipe(command string, args []string, o io.Writer, e io.Writer) ([]byte, []byte, error)
- func FileConvertToUTF8(file io.Reader, charset string) (io.Reader, error)
- func FileGuessEncoding(bytes []byte) string
- func InitZapLog(v *viper.Viper) (*zap.Logger, error)
- func MapGetKeys(m interface{}) ([]interface{}, error)
- func MapGetSortedKeys(m interface{}, reverse bool) interface{}
- func MapRemoveNulls(m map[string]interface{})
- func MapStringMerge(map1, map2 interface{}) (interface{}, error)
- func SliceFindElemStr(slice []string, val string) int
- func SliceIsElemIn(array []interface{}, elem interface{}, fn CompareFunc) int
- func StringBuild(strs ...string) string
- func StringBuildWithSep(sep rune, strs ...string) string
- func StringConvertToMapSimple(str, elSep, kvSep string) (map[string]interface{}, error)
- func StringParseFloat(str string) (float64, error)
- func StringStripAnsi(str string) string
- type CompareFunc
- type JWTToken
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTokenInvalid denotes a token was not able to be validated. ErrTokenInvalid = errors.New("JWT Token was invalid") // ErrTokenExpired denotes a token'vs expire header (exp) has since passed. ErrTokenExpired = errors.New("JWT Token is expired") // ErrTokenMalformed denotes a token was not formatted as a JWT token. ErrTokenMalformed = errors.New("JWT Token is malformed") // ErrTokenNotActive denotes a token's not before header (nbf) is in the // future. ErrTokenNotActive = errors.New("Token is not valid yet") // ErrTokenUnexpectedSigningMethod denotes a token was signed with an unexpected // signing method. ErrTokenUnexpectedSigningMethod = errors.New("Token unexpected signing method") // ErrTokenUnableGetCAPublic denotes not being able to get CA Public Key ErrTokenUnableGetCAPublic = errors.New("Token cannot get CA Public Key") // ErrTokenKidNotFound denotes token's key identifier not found ErrTokenKidNotFound = errors.New("Token's Key Identifier not found") )
Functions ¶
func BytesConvertToUTF8 ¶ added in v0.2.0
BytesConvertToUTF8 converts bytes from a given encoding to UTF8
func BytesMarshal ¶
BytesMarshal converts a type interface to byte array
func BytesUnMarshal ¶
BytesUnMarshal put data of a byte array to a type interface
func ExecCmdPipe ¶
ExecCmdPipe executes command shell. It redirects output and errors to standard and then stores in a bytes. It returns command's stdout and stderr in bytes and error of command execution
func FileConvertToUTF8 ¶ added in v0.2.0
FileConvertToUTF8 converts a file from a given encoding to UTF-8
func FileGuessEncoding ¶ added in v0.2.0
FileGuessEncoding tries to guess the encoding of bytes.
It recognizes UTF-8, UTF-32LE, UTF-32BE, UTF-16LE, UTF-16BE, windows-1252, iso-8859-1.
func MapGetKeys ¶
func MapGetKeys(m interface{}) ([]interface{}, error)
MapGetKeys returns a slice of keys.
func MapGetSortedKeys ¶
func MapGetSortedKeys(m interface{}, reverse bool) interface{}
MapGetSortedKeys returns a sorted slice contaning keys of map as interface{}// and need to be casted in the format as you want
This function supports the following type of key: string, int If the given parameter is not a map, it will return nil
func MapRemoveNulls ¶
func MapRemoveNulls(m map[string]interface{})
MapRemoveNulls removes all fields with nil value
func MapStringMerge ¶
func MapStringMerge(map1, map2 interface{}) (interface{}, error)
MapStringMerge merges 2 string maps of the same type: map2 in map1.
If an element in map1 does not exist, it will be created. Otherwise, it will be overrided by new value in map2
func SliceFindElemStr ¶
SliceFindElemStr takes a slice and looks for an element in it. If found it will return the element's position. Otherwise it will return -1
func SliceIsElemIn ¶
func SliceIsElemIn(array []interface{}, elem interface{}, fn CompareFunc) int
SliceIsElemIn checks if an element is in an array of elements of the same type
func StringBuild ¶
StringBuild concatenates strings together
func StringBuildWithSep ¶
StringBuildWithSep concatenates strings together with a separator
func StringConvertToMapSimple ¶
StringConvertToMapSimple converts a string composed of key/value elements separated by a separator to a map. By default, the separator for key and value is ":" and the separator for each key/value element is ";"
func StringParseFloat ¶
StringParseFloat is an advance ParseFloat for golang, support scientific notation, comma separated number.
Examples: StringParseFloat("1E2") = 100) StringParseFloat("1E-5") = 0.00001) StringParseFloat("1.6543E2") = 165.43) StringParseFloat("0.89E2") = 89) StringParseFloat("1.6543E-2") = 0.016543) StringParseFloat("156,819,129") = 156819129) StringParseFloat("156819129") = 156819129) StringParseFloat(".1E0") = 0.1) StringParseFloat(".1E1") = 1) StringParseFloat("0E1") = 0)
func StringStripAnsi ¶
StringStripAnsi removes ANSI escape code from string
Types ¶
type CompareFunc ¶
type CompareFunc func(elem1 interface{}, elem2 interface{}) bool
CompareFunc is utility func to compare 2 elements
type JWTToken ¶
type JWTToken struct {
// contains filtered or unexported fields
}
JWTToken represents struct containing signing key or jwks°uri
func (*JWTToken) ParseToken ¶
ParseToken parses and checks to see if JWT is valid. If the token is valid, it returns a map of all claims defined in the JWT.
func (*JWTToken) SetJwksURI ¶
SetJwksURI sets jwksURI to validate token
func (*JWTToken) SetSignKey ¶
SetSignKey set signKey to use when jwksURI is not used. It will be used to sign/verify the token.
func (*JWTToken) SetSignMethod ¶
SetSignMethod set signing method to sign or verify the token