Documentation
¶
Overview ¶
Package util holds various utilities used all over gggb
Index ¶
- Constants
- func AddZwsp(s string) string
- func AnyMaskMatch(toCheck string, masks []string) bool
- func CleanSplitOnSpace(s string) []string
- func EscapeString(s string) string
- func GenerateSASLString(nick, saslUsername, saslPasswd string) string
- func GlobToRegexp(mask string) *regexp.Regexp
- func IdxOrEmpty(slice []string, idx int) string
- func JoinToMaxLength(toJoin []string, sep string, maxLength int) []string
- func MakeSimpleIRCLine(command string, args ...string) ircmsg.IrcMessage
- func ReverseIdx(toIdx []string, idx int) string
- func StripAll(s string) string
- func UserHost2Canonical(uh ircutils.UserHost) string
- func WordEol(s string, wordIdx int) string
Examples ¶
Constants ¶
const ( RPL_LOGGEDIN = "900" RPL_LOGGEDOUT = "901" RPL_NICKLOCKED = "902" RPL_SASLSUCCESS = "903" RPL_SASLFAIL = "904" RPL_SASLTOOLONG = "905" RPL_SASLABORTED = "906" RPL_SASLALREADY = "907" RPL_SASLMECHS = "908" )
IRC SASL numerics
Variables ¶
This section is empty.
Functions ¶
func AddZwsp ¶
AddZwsp adds a zero width space to the given string if its length is greater than two
func AnyMaskMatch ¶
AnyMaskMatch returns whether or not the given match
func CleanSplitOnSpace ¶
CleanSplitOnSpace splits the given string on space specifically without adding empty strings to the resulting array for repeated spaces
func EscapeString ¶
EscapeString escapes commonly (ab)used strings
func GenerateSASLString ¶
GenerateSASLString generates a base64 encoded string from the given parameters that can be used for SASL PLAIN authentication with an IRC server
func GlobToRegexp ¶
GlobToRegexp converts a mask glob string to a regexp that will only allow the wildcards * and ? to have any special meaning.
func IdxOrEmpty ¶
IdxOrEmpty returns the given slice index, or an empty string
Example ¶
s := []string{"test", "string", "is", "testy"} fmt.Printf("%q\n", IdxOrEmpty(s, 0)) fmt.Printf("%q\n", IdxOrEmpty(s, 5)) //nolint:gocritic // its output :P
Output: "test" ""
func JoinToMaxLength ¶
JoinToMaxLength takes a string slice and joins it on sep until the joined string cannot be made larger without crossing maxLength length. If any entry in the slice to be joined is larger than maxLength, it will be added on its own to an entry in the resulting slice
Example ¶
fmt.Printf("%#v", JoinToMaxLength([]string{"this", "is", "a", "test"}, ", ", 10))
Output: []string{"this, is", "a, test"}
func MakeSimpleIRCLine ¶
func MakeSimpleIRCLine(command string, args ...string) ircmsg.IrcMessage
MakeSimpleIRCLine is a helper function that creates an ircmsg.IrcMessage with no tags and no prefix.
func ReverseIdx ¶
ReverseIdx returns either the given index, or, if the given index is negative, that index starting from the end of the slice. Much like a python lists behaviour when indexed with a negative number
Example ¶
fmt.Println(ReverseIdx([]string{"have", "an", "example", "string", "slice"}, -2))
Output: string
func StripAll ¶
StripAll strips any extra weird ascii control codes
Example ¶
fmt.Println(StripAll("Some string with \x01 control characters\u200b in it"))
Output: Some string with control characters in it
func UserHost2Canonical ¶
UserHost2Canonical returns the nickname!username@host representation of the given ircutils.UserHost
Types ¶
This section is empty.
Directories
¶
Path | Synopsis |
---|---|
Package systemstats holds code to query the status of the current system
|
Package systemstats holds code to query the status of the current system |