Documentation ¶
Overview ¶
Package mk provides type-inference wrappers around make().
Sometimes when calling make(T), T has already been declared elsewhere. For example, if initializing a map in a struct, you might wind up with a situation like
struct Example { Values map[string]any } func NewExample() *Example { return &Example{Values: make(map[string]any)} }
Note how the type of the map is repeated. It is this exact situation that this package is for. Instead of repeating the type, you can use this package to eliminate the repetition:
func NewExample() *Example { var ex Example mk.Map(&ex.Values, 0) return &ex }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Map ¶
func Map[M ~map[K]V, K comparable, V any](m *M, cap int)
Map makes a map of the given capacity and stores it in m.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.