Skip to content
Node: Object.values(obj)github.com/sahilkhaire/gox/maputil

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) []V

Compare: 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) }

Back to maputil package overview

MIT Licensed · Built for Node.js developers moving to Go