utils

package
v0.0.0-...-5119766 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CastStringLikeSlice

func CastStringLikeSlice[T ~string, V ~string](in []T) []V

CastStringLikeSlice converts between slices of string-like types

func EscapeMarkdownCharacters

func EscapeMarkdownCharacters(s string) string

EscapeMarkdown is like escape.MarkdownCharacters but aware of JungleTV-specific chat markdown extensions

func GetUniquifiedIP

func GetUniquifiedIP(remoteAddress string) string

GetUniquifiedIP returns a uniquified version of an IP address (sets the lower bits of a IPv6 to zero, leaves IPv4 untouched)

func NewRateLimiterMemoryStoreWithContext

func NewRateLimiterMemoryStoreWithContext(ctx context.Context, config *memorystore.Config) (limiter.Store, error)

NewRateLimiterMemoryStoreWithContext creates a new in-memory rate limiter with the given config and takes care of its closure when the context is done

func ReplaceAllStringSubmatchFunc

func ReplaceAllStringSubmatchFunc(re *regexp.Regexp, str string, repl func([]string) string) string

ReplaceAllStringSubmatchFunc is a version of func (*regexp.Regexp) ReplaceAllStringFunc that passes submatches to the callback. It follows the "semantic naming" convention for functions in the regexp package. Based on the implementation found at https://elliotchance.medium.com/go-replace-string-with-regular-expression-callback-f89948bad0bb

func ReplaceAllStringSubmatchFuncExcludingInside

func ReplaceAllStringSubmatchFuncExcludingInside(re, excludeInside *regexp.Regexp, str string, repl func([]string) string) string

ReplaceAllStringSubmatchFuncExcludingInside works like ReplaceAllStringSubmatchFunc, but it does not perform any replacements in regions that match the regexp passed as the second argument

func SliceToSet

func SliceToSet[T comparable](s []T) map[T]struct{}

SliceToSet returns a map-based set with the elements of the specified slice

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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