util

package
v0.0.0-...-2b7f6e1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateID

func GenerateID(size int) string

GenerateID generates a random ASCII-safe string of specified length

func GenerateName

func GenerateName() string

GenerateName generates a slug in the format "cornflake-peddling-bp0q".

func LoadWordsFile

func LoadWordsFile(filename string) error

LoadWordsFile imports the word definition file used for names.

func Sanitize

func Sanitize(in string) string

Sanitize is a very light-weight attempt to reduce XSS potential in well-behaved clients

Types

type Safemap

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

Safemap is a special-purpose map type for holding unsigned-ints or bools intended for use in http requests or performance-critical paths

func NewSafemap

func NewSafemap() *Safemap

NewSafemap returns an initialized pointer to a Safemap

func (*Safemap) Get

func (sm *Safemap) Get(key string) (uint64, bool)

Get returns a uint64 value, if it exists in the map

func (*Safemap) GetBool

func (sm *Safemap) GetBool(key string) bool

GetBool returns a bool value from the map -- false for missing key

func (*Safemap) Increment

func (sm *Safemap) Increment(key string)

Increment automatically increments the value in the map

func (*Safemap) Set

func (sm *Safemap) Set(key string, value uint64)

Set sets a uint64 value into the map

func (*Safemap) SetBool

func (sm *Safemap) SetBool(key string, value bool)

SetBool sets a boolean value into the map

Jump to

Keyboard shortcuts

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