basicnew

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 0 Imported by: 0

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.

Jump to

Keyboard shortcuts

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