Documentation ¶
Overview ¶
Package utils provides utility functions.
This is bad practice to name like this. I know.
Index ¶
- func Flush[T any](msgChan chan T)
- func GenerateRandomString(n int) string
- func GetFirstValuableErrorOrFirst(errs []error) error
- func JSONDecodeAndPrintOnError(r io.Reader, v any) error
- func MockRandomString(s string)
- func MustJSONEncode(v any) string
- func OverrideRandSource(s rand.Source)
- func SanitizeFilename(filename string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Flush ¶ added in v0.3.4
func Flush[T any](msgChan chan T)
Flush flushes the messages from the channel.
func GenerateRandomString ¶ added in v1.7.0
GenerateRandomString generates a random string of length n.
func GetFirstValuableErrorOrFirst ¶ added in v1.8.4
GetFirstValuableErrorOrFirst returns the first error that is not nil, not EOF, and not context.Canceled. If not found, returns the first error.
func JSONDecodeAndPrintOnError ¶ added in v1.8.4
JSONDecodeAndPrintOnError decodes JSON from the reader and logs the raw JSON on error.
func MockRandomString ¶ added in v1.7.0
func MockRandomString(s string)
MockRandomString mocks the random string generation.
func MustJSONEncode ¶ added in v1.6.4
MustJSONEncode encodes the value to JSON or panic.
func OverrideRandSource ¶ added in v1.7.0
OverrideRandSource overrides the random source.
func SanitizeFilename ¶
SanitizeFilename sanitizes the filename.
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package channel describes functions for working with channels.
|
Package channel describes functions for working with channels. |
Package ptr provides a simple way to get the pointer of a value.
|
Package ptr provides a simple way to get the pointer of a value. |
Package try provides a set of functions to retry a function with a delay.
|
Package try provides a set of functions to retry a function with a delay. |
Click to show internal directories.
Click to hide internal directories.