util

package
v0.0.0-...-df8c4e2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNumeric

func IsNumeric(str string) bool

IsNumeric is a helper function to determine if a string is a number.

func NewStrictJSONDecoder

func NewStrictJSONDecoder(r io.Reader) *json.Decoder

NewStrictJSONDecoder constructs a new JSON decoder with strict settings.

func ParseFloat

func ParseFloat[E Float](s string) (E, error)

func ParseInt

func ParseInt[E signed](s string) (E, error)

func ParseMemberIDs

func ParseMemberIDs(ids string) ([]int64, error)

ParseMemberIDs is a helper function to parse member IDs for groups and rooms.

func ParseOptionalBool

func ParseOptionalBool(s string) (bool, error)

ParseOptionalBool will return false if the input string is empty,

If the sting is not empty and the parsed value is invalid it will return an error instead.

Otherwise, it will return the correctly parsed bool value.

func ParseUInt

func ParseUInt[E unsigned](s string) (E, error)

func SliceContains

func SliceContains[T comparable](needle T, haystack []T) bool

Types

type Float

type Float interface {
	~float32 | ~float64
}

type Integer

type Integer interface {
	signed | unsigned
}

Jump to

Keyboard shortcuts

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