util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

util implements trivial util functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert[T any](v any) (asserted T, ok bool)

Assert does type assertion on v. v is asserted against T and *T. Assert returns true ok when v is either of T or *T. If v is nil *T, then asserted is zero value of T.

func Escape

func Escape[T any](v T) *T

Escape escapes v to a pointer of v.

It is useful when setting built-in type T (e.g. string, int) to struct fields of *T.

func Must

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

Must unwraps error probability from return value of functions so that you can use it in outside of function easily.

It panic if err is non nil.

func Must3

func Must3[T any, U any](val1 T, val2 U, err error) (T, U)

Must3 is same as Must but takes 3 args.

It panics if err is non nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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