internal

package
v0.0.0-...-1adbf8b Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must[T any](a T, err error) T

Must panics if the error is non-nil. It is intended for use in variable initializations such as f := internal.MustNoErr(os.OpenFile("notes.txt", os.O_RDONLY, 0600))

func MustNoErr

func MustNoErr(err error)

MustNoErr logs the error message and exits, if the error is non-nil. It is intended for use statements that could return an error and continued execution is not meaningful.

func MustOk

func MustOk[T any](a T, ok bool) T

MustOk is similar to Must, but for the "comma ok" idiom. It is intended for use in statements like str := internal.MustOk(arg.(string))

func MustTuple

func MustTuple[A any, B any](a A, b B, err error) (A, B)

MustTuple is like Must, but for functions where three values are returned.

func NilToZero

func NilToZero[T any](i any) (ret T)

NilToZero returns the zero value of type T, if the argument is nil. Otherwise, it casts the value and returns the value. Note that this function panics if the value cannot be cast to type T.

func Parse

func Parse(s string) any

Parse attempts to interpret the string as boolean or integer and returns it. Otherwise, it returns the value itself, regardless of its type.

func ReSlice

func ReSlice[T any](es []any) []T

ReSlice creates a new slice of T and inserts all elements from the original. It is assumed that all elements are of type T.

func Second

func Second[A any, B any](_ A, b B) B

Second returns the second argument. It is intended for use in places like return, where the second return value of a function call should be returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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