util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeySlice

func KeySlice[M ~map[K]V, K comparable, V any](m M) []K

KeySlice returns the keys of the map M, like slices.Collect(maps.Keys(m)).

func Sorted

func Sorted[M ~map[K]V, K cmp.Ordered, V any](m M) iter.Seq2[K, V]

Sorted returns an iterator over the entries of m in key order.

func Wrapf

func Wrapf(errp *error, format string, args ...any)

Wrapf wraps *errp with the given formatted message if *errp is not nil.

Types

type JSONInfo

type JSONInfo struct {
	Omit     bool            // unexported or first tag element is "-"
	Name     string          // Go field name or first tag element. Empty if Omit is true.
	Settings map[string]bool // "omitempty", "omitzero", etc.
}

func FieldJSONInfo

func FieldJSONInfo(f reflect.StructField) JSONInfo

FieldJSONInfo reports information about how encoding/json handles the given struct field. If the field is unexported, JSONInfo.Omit is true and no other JSONInfo field is populated. If the field is exported and has no tag, then Name is the field's name and all other fields are false. Otherwise, the information is obtained from the tag.

Jump to

Keyboard shortcuts

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