Documentation ¶
Overview ¶
Example ¶
package main import ( "fmt" "sort" "github.com/jeremmfr/go-utils/basicnew" ) func main() { aMap := map[string]int{ "bar": 1, "foo": 2, } keys := basicnew.MapKeys(aMap) sort.Strings(keys) fmt.Println(keys) }
Output: [bar foo]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MapKeys ¶
func MapKeys[K comparable, V any](m map[K]V) []K
MapKeys generate a new slice with all keys of a map.
Example ¶
package main import ( "fmt" "sort" "github.com/jeremmfr/go-utils/basicnew" ) func main() { aMap := map[string]string{ "bar": "baz", "foo": "baz", } keys := basicnew.MapKeys(aMap) sort.Strings(keys) fmt.Println(keys) }
Output: [bar foo]
func MapValues ¶
func MapValues[K comparable, V any](m map[K]V) []V
MapValues generate a new slice with all values of a map.
Example ¶
package main import ( "fmt" "github.com/jeremmfr/go-utils/basicnew" ) func main() { aMap := map[string]string{ "bar": "baz", "foo": "baz", } values := basicnew.MapValues(aMap) fmt.Println(values) }
Output: [baz baz]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.