mak

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: BSD-3-Clause Imports: 2 Imported by: 68

Documentation

Overview

Package mak helps make maps. It contains generic helpers to make/assign things, notably to maps, but also slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NonNil

func NonNil(ptr interface{})

NonNil takes a pointer to a Go data structure (currently only a slice or a map) and makes sure it's non-nil for JSON serialization. (In particular, JavaScript clients usually want the field to be defined after they decode the JSON.) MakeNonNil takes a pointer to a Go data structure (currently only a slice or a map) and makes sure it's non-nil for JSON serialization. (In particular, JavaScript clients usually want the field to be defined after they decode the JSON.)

func Set

func Set[K comparable, V any, T ~map[K]V](m *T, k K, v V)

Set populates an entry in a map, making the map if necessary.

That is, it assigns (*m)[k] = v, making *m if it was nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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