structs

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package structs provides utility functions for working with structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](s []T, e T) bool

Contains checks if a slice contains a specific element. It takes a slice and an element as parameters. It returns true if the element is found in the slice, otherwise it returns false.

func MapContains

func MapContains[K comparable, V any](m map[K]V, k K) bool

MapContains checks if a map contains a specific key. It takes a map and a key as parameters. It returns true if the key is found in the map, otherwise it returns false.

func MapKeys

func MapKeys[K comparable, V any](m map[K]V) []K

MapKeys returns all keys from a map. It takes a map as a parameter. It returns a slice containing all keys from the map.

func MapSort

func MapSort[K ~string | ~int, V any](m map[K]V) map[K]V

MapSort sorts a map by its keys. It takes a map as a parameter. It returns a new map with the same key-value pairs, but sorted by keys. The sorting is only applicable for maps with string or integer keys.

Types

This section is empty.

Jump to

Keyboard shortcuts

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