must

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package must contains utilities for testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Atoi

func Atoi(s string) int

Atoi converts s to an integer using strconv.Atoi, or panics if s is not a valid integer

func B64

func B64(encoded string) []byte

B64 decodes `encoded` using base64.StdEncoding

func Close

func Close(closer io.Closer)

Close closes closer and panics if Close() returns a non-nil error

func DecodeBase64

func DecodeBase64(encoding *base64.Encoding, encoded string) []byte

DecodeBase64 decodes the base64 encoded string in encoded, or panics if it is not a valid string.

func DecodeHex

func DecodeHex(encoded string) []byte

DecodeHex decodes the hex-encoded string in encoded, or panics if it is not a valid string.

func MarshalJSON

func MarshalJSON(v interface{}) []byte

MarshalJSON returns the JSON encoding of v, or panics if v cannot be encoded.

func MarshalJSONPretty

func MarshalJSONPretty(v interface{}) []byte

MarshalJSONPretty returns the JSON encoding of v, or panics if v cannot be encoded.

func NotFail

func NotFail(err error)

NotFail panics if err is not nil

func ParseTime

func ParseTime(s string) time.Time

ParseTime returns the time.Time value represented by the string s in RFC3339 format.

func ParseURL

func ParseURL(s string) *url.URL

ParseURL parses the specified URL, panicing if it is not valid

func ReadFile

func ReadFile(filename string) []byte

ReadFile returns the contents of the specified file.

func ReadFileFS

func ReadFileFS(fs fs.FS, filename string) []byte

ReadFileFS returns the contents of the specified file.

func ReadRandomBytes

func ReadRandomBytes(n int) []byte

ReadRandomBytes returns a random buffer of length n, or panics if bytes cannot be obtained.

Uses thunks.RandReader as the source of randomness.

func ReadRandomInteger

func ReadRandomInteger(maxValue uint64) uint64

ReadRandomInteger returns an integer between [0, maxValue). It panics if max = 0 or if random bytes cannot be read.

func Return

func Return[T any](value T, err error) T

Return is useful for functions returning (value, error). It panics if err is not nil, otherwise it returns the value.

func UnmarshalJSON

func UnmarshalJSON[T any](data []byte) T

UnmarshalJSON parses JSON-encoded data, or panics if data cannot be decoded.

func WriteFile

func WriteFile(filename string, content []byte)

WriteFile writes the specified file

Types

This section is empty.

Jump to

Keyboard shortcuts

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