Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](arr []T, target T) bool
Contains checks if a target item exists in an array of any type.
Example:
names := []string{"Alice", "Bob", "Carol"} result := Contains(names, "Bob")
Result:
true
func GetJSONTags ¶
func GetJSONTags(v interface{}) []string
GetJSONTags retrieves all JSON tag values from a struct. It returns a slice of JSON tag values extracted from the struct's fields.
Example:
type Person struct { ID int `json:"id"` Name string `json:"name"` Age int `json:"age"` CreatedAt string `json:"created_at"` } p := Person{} jsonTags := GetJSONTags(p)
Result:
["id", "name", "age", "created_at"]
func GetMapKeys ¶
func GetMapKeys[K comparable, V any](m map[K]V) []K
GetMapKeys is a generic function that extracts all keys from a map and returns them in a slice.
Example:
ageMap := map[string]int{"Alice": 30, "Bob": 25, "Carol": 27} keys := GetMapKeys(ageMap)
Result:
["Alice", "Bob", "Carol"]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.