Values
Overview
Values returns map values (Object.values).
If you are coming from Node.js, the closest pattern is Object.values(obj).
Signature
go
func Values[K comparable, V any](m map[K]V) []VCompare: Node.js · Standard Go · gox
js
Object.values(obj)go
keys := make([]string, 0, len(m))
for k := range m { keys = append(keys, k) }go
import "github.com/sahilkhaire/gox/maputil"
maputil.Values(obj)Example
go
import "github.com/sahilkhaire/gox/maputil"
maputil.Values(obj)Tips
Import github.com/sahilkhaire/gox/maputil and call Values directly. See the comparison below for the standard library equivalent.
Standard library alternative
Use the standard library directly:
go
keys := make([]string, 0, len(m))
for k := range m { keys = append(keys, k) }