misc

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package misc implements miscellaneous functions.

Package misc implements miscellaneous functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Atoi64 added in v0.2.0

func Atoi64(s string) (int64, error)

Atoi64 is a strconv.Atoi like wrapper for int64s.

func Attribute

func Attribute[S, A any](seq iter.Seq[S], a A) iter.Seq2[S, A]

Attribute returns a sequence attributing the given one with a given attribute.

func CalculateEndpoint added in v0.3.0

func CalculateEndpoint(begin time.Time, end time.Time) time.Time

CalculateEndpoint determines whether time.Now is happening during a duration from a set point in time. If it is, then time.Now() is returned, otherwise the endpoint of the duration is returned.

func CompareEmptyStrings added in v0.2.0

func CompareEmptyStrings(a, b *string) int

CompareEmptyStrings compares to strings.

func EmptyString added in v0.2.0

func EmptyString(s *string) string

EmptyString returns an empty string if the pointer is nil the dereferenced string otherwise.

func EncodePassword

func EncodePassword(password string) string

EncodePassword encodes a password to be stored in the database.

func Filter

func Filter[S any](seq iter.Seq[S], cond func(S) bool) iter.Seq[S]

Filter returns a filtered by cond sequence of the given one.

func Join2

func Join2[K, V any](seqs ...iter.Seq2[K, V]) iter.Seq2[K, V]

Join2 joins a list of sequences.

func Map

func Map[S, T any](seq iter.Seq[S], xform func(S) T) iter.Seq[T]

Map returns a map iterator on a sequence.

func NilChanger added in v0.2.0

func NilChanger(changed *bool, s **string, v string)

NilChanger updates a potential nil string.

func NilString added in v0.2.0

func NilString(s string) *string

NilString returns nil if the given string is empty else a pointer to the string is returned.

func ParseSeq added in v0.2.0

func ParseSeq[S, T any](seq iter.Seq[S], parse func(S) (T, error)) iter.Seq[T]

ParseSeq parses the elements of a given sequence with a given parse function and returns a sequence of the parsing results that do not fail to parse.

func ParseSeq2 added in v0.3.0

func ParseSeq2[S, K, V any](seq iter.Seq[S], parse func(S) (K, V, error)) iter.Seq2[K, V]

ParseSeq2 parses the elements of a given sequence with a given parse function and returns a sequence of the parsing results that do not fail to parse.

func RandomString

func RandomString(n int) string

RandomString generates a random string of length n.

func Shorten added in v0.2.0

func Shorten(v any) string

Shorten shortens a string to max. 40 characters.

func Values

func Values[S any](args ...S) iter.Seq[S]

Values returns an iterator over the variadic args.

Types

This section is empty.

Jump to

Keyboard shortcuts

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