util

package
v0.0.0-...-c930397 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MilliClock func() time.Duration

Clock returns the number of milliseconds that have elapsed since the program was started.

Functions

func ByteReplace

func ByteReplace(bytes []byte, from, to byte) []byte

ByteReplace replaces any occurrence of byte `from` to `to` in `bytes`.

func BytesToString

func BytesToString(b []byte) string

BytesToString unsafely converts a []byte to a string. DO NOT MODIFY the []byte!

func ContainsCJK

func ContainsCJK(str string) bool

ContainsCJK returns whether a string contains any CJK characters.

func CurrentTimeMillis

func CurrentTimeMillis() int64

CurrentTimeMillis gets the current time in milliseconds since UNIX epoch.

func FirstWordIsQuestion

func FirstWordIsQuestion(runes []rune) bool

FirstWordIsQuestion returns whether the first word of a []rune indicates a question.

func Format

func Format(input string, isCJK bool) string

Format formats a message for chat storage.

func FormatCacheJanitor

func FormatCacheJanitor()

FormatCacheJanitor cleans up the message format cache in the background.

func FormatMsg

func FormatMsg(input string, isCJK bool) string

FormatMsg formats a message, bypassing the format cache.

func GetElemAt

func GetElemAt(targetIdx int, list *container_list.List) *container_list.Element

GetElemAt retrieves the element at targetIdx of list.

func IP2Int

func IP2Int(ip net.IP) uint32

IP2Int converts a net.IP to an uint32 IP.

func Int2IP

func Int2IP(nn uint32) net.IP

Int2IP converts an uint32 IP to a net.IP.

func IsPunct

func IsPunct(r rune) bool

IsPunct returns whether a rune is an ending punctuation symbol or not.

func Metaphone

func Metaphone(s string) (string, string)

func RuneReplace

func RuneReplace(runes []rune, from, to rune) []rune

RuneReplace replaces any occurrence of rune `from` to `to` in `runes`.

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes unsafely converts a string to a []byte. DO NOT MODIFY the []byte!

Types

type Contraction

type Contraction struct {
	Contracted      string
	Expanded        []string
	ShouldContract  bool
	OnlyIfFirstWord bool
}

type FormatResults

type FormatResults struct {
	// contains filtered or unexported fields
}

FormatResults stores the results from a successful string format.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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