util

package
v0.0.0-...-6573677 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any[T any](slice []T, predicate func(input T) bool) bool

Any checks if any element of input slice causes the predicate to return true.

func Filter

func Filter[T any](slice []T, predicate func(input T) bool) []T

Filter the given slice, keeping only the ones that cause the predicate to return true.

func Find

func Find[T any](slice []T, predicate func(input T) bool) *T

Find the first element in the given slice that causes the predicate to return true; if not found, returns nil.

func Map

func Map[F any, T any](slice []F, mapper func(input F) T) []T

Map an input slice to an output slice with the given mapper function.

func PrettyXML

func PrettyXML(input []byte) ([]byte, error)

func RandomList

func RandomList[T any](maxLength int, gen func() T) []T

RandomList returns a random list with a length no more than specified, where each element is generated with the given function.

func RandomString

func RandomString() string

RandomString returns a random non-empty string of an unspecified length

func RandomStringWithLength

func RandomStringWithLength(length int) string

RandomStringWithLength returns a random string with a given length

func RandomTime

func RandomTime() time.Time

RandomTime returns a random time

Types

type XMLElement

type XMLElement struct {
	XMLName  xml.Name
	Attr     []xml.Attr   `xml:",any,attr"`
	Children []XMLElement `xml:",any"`
	Text     string       `xml:",chardata"`
	Comment  string       `xml:",comment"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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