Documentation
¶
Index ¶
- Constants
- Variables
- func Abs(n int) int
- func Abs64(n int64) int64
- func BoolPtr(v bool) *bool
- func BytesToFloat32(bytes []uint8) float32
- func BytesToUint64(bytes []uint8) (v uint64)
- func CeilInt(f float64) int
- func CheckFlag(value, flag uint32) bool
- func ChunkStringSlice(in []string, n int) (out [][]string, err error)
- func CombineUint32(val1, val2 uint32) uint64
- func CustomDurationString(diff time.Duration, numParts int, glue string) string
- func CustomRelTime(t1, t2 time.Time, numParts int, glue string) string
- func DurationString(diff time.Duration) string
- func FilterChannelName(username string) string
- func FilterUserIDs(potentialUserIDs []string) (userIDs []string)
- func FilterUsername(username string) string
- func FilterUsernames(potentialUsernames []string) (usernames []string)
- func Float32ToString(v float32) string
- func FloorInt(f float64) int
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(n int) (string, error)
- func GenerateRandomStringURLSafe(n int) (string, error)
- func GetEnv(key, fallback string) string
- func GetTriggers(message string) []string
- func GetTriggersKC(message string) []string
- func GetTriggersN(message string, n int) []string
- func InsertUnique(text string, target *[]string)
- func Int32ToBytes(value int32) (bytes []byte)
- func IsNotAlphanumeric(r rune) bool
- func IsNotLatinLetter(r rune) bool
- func IsValidUserID(userID string) bool
- func IsValidUsername(username string) bool
- func MakeVariations(text string, doNormalize bool) (originalVariations, lowercasedVariations []string, err error)
- func MaxInt(a, b int) int
- func MaxInt64(a, b int64) int64
- func MinInt(a, b int) int
- func NewStringPtr(s string) *string
- func ParseDuration(s string) (time.Duration, error)
- func RandIntN(min, max int) (int, error)
- func ReadArg(reader *bufio.Reader) string
- func RelTime(t1, t2 time.Time) string
- func RemoveInStringFunc(in string, predicate RemoveFunc) string
- func RemoveNewlines(s string) string
- func Round(val float64, places int) (newVal float64)
- func SBKey(m map[string]bool) (keys []string)
- func SplitUint64(val uint64) (p1, p2 uint32)
- func StringContains(needle string, haystack []string) bool
- func Sum(s []int) int
- func TimeSince(t2 time.Time) string
- func Uint32ToBytes(value uint32) (bytes []byte)
- func Uint64ToBytes(value uint64) (bytes []byte)
- func UnpingifyUsername(username string) string
- func WebWrite(w http.ResponseWriter, data interface{}) error
- func WebWriteError(w http.ResponseWriter, code int, errorString string) error
- type RemoveFunc
- type WebAPIError
Constants ¶
Variables ¶
var ( CarriageReturn = []byte{'\r'} LineFeed = []byte{'\n'} CRLF = []byte("\r\n") Space = []byte{' '} )
Functions ¶
func BytesToFloat32 ¶
BytesToFloat32 takes a slice of 4 bytes and converts it to a float32 value
func BytesToUint64 ¶
BytesToUint64 takes a slice of 8 bytes and returns an uint64 value NOTE: bytes must be 8 length here, or else it will panic. it should just return an error value
func ChunkStringSlice ¶
arr = ["a", "b", "c", "d", "e"] ChunkStringSlice(arr, 2) ret = [ [ "a", "b"], ["c", "d"], ["e"] ]
func CombineUint32 ¶
CombineUint32 returns the packed uint64 value of two uint32's
func CustomDurationString ¶
func DurationString ¶
func FilterChannelName ¶
func FilterUserIDs ¶
func FilterUsername ¶
func FilterUsernames ¶
func Float32ToString ¶
FloatToString converts a float value to a string with sane defaults
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomStringURLSafe ¶
GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GetEnv ¶
GetEnv returns an environment key from the system, with an optional value if the environment key isn't set
func GetTriggers ¶
GetTriggers returns a list of strings that have been parsed in accordance to the command rules
func GetTriggersKC ¶
GetTriggersKC returns a list of strings that have been parsed in accordance to the command rules, but keeps the case
func GetTriggersN ¶
GetTriggersN returns a list of strings that have been parsed in accordance to the command rules. Offset by N
func InsertUnique ¶
InsertUnique inserts a string into a target string splice if it doesn't already exist in it
func Int32ToBytes ¶
Int32ToBytes converts a int32 value into a slice of its 4 bytes
func IsNotAlphanumeric ¶
func IsNotLatinLetter ¶
func IsValidUserID ¶
IsValidUserID verifies that the given user id is not empty, and that it only contains valid characters It does not to any length-checks, as there are no clear rules as to how short or long a user ID can be
func IsValidUsername ¶
IsValidUsername verifies that the given user name is not empty, and that it only contains valid characters (0-9 a-z A-Z _) It does not to any length-checks, as there are no unbroken rules as to how short or long a user name can be
func MakeVariations ¶
func MakeVariations(text string, doNormalize bool) (originalVariations, lowercasedVariations []string, err error)
MakeVariations makes normal-case and lowercase variatinos of a string
func NewStringPtr ¶
NewStringPtr returns the pointer to the given string
func RandIntN ¶
RandIntN generates a number between min and max (inclusive). Only works with positive numbers.
func RemoveInStringFunc ¶
func RemoveInStringFunc(in string, predicate RemoveFunc) string
func RemoveNewlines ¶
RemoveNewlines replaces all \r and \n with spaces
func SplitUint64 ¶
SplitUint64 spits a uint64 value into two uint32 values
func StringContains ¶
func Uint32ToBytes ¶
Uint32ToBytes converts a uint32 value into a slice of its 4 bytes
func Uint64ToBytes ¶
Uint64ToBytes converts a uint64 value into a slice of its 8 bytes
func UnpingifyUsername ¶
func WebWrite ¶
func WebWrite(w http.ResponseWriter, data interface{}) error
func WebWriteError ¶
func WebWriteError(w http.ResponseWriter, code int, errorString string) error
Types ¶
type RemoveFunc ¶
type WebAPIError ¶
func NewWebAPIError ¶
func NewWebAPIError(code int, errorString string) WebAPIError