Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromStruct ¶
FromStruct is a helper function to make map[string]any from struct
func Get ¶
Get is a helper function to get value from map[string]any it's posible to get value from nested map by using dot (.) as separator
Example ¶
package main
import (
"fmt"
"github.com/gowok/gowok/maps"
)
func main() {
var m = map[string]any{
"mantap": "jos",
"gandos": map[string]any{
"jos": "yoi",
},
}
fmt.Println(maps.Get[string](m, "gandos.jos"))
}
Output: yoi
func MapToStruct
deprecated
func ToStruct ¶
ToStruct is a helper function to convert map[string]any to struct
Example ¶
package main
import (
"fmt"
"github.com/gowok/gowok/maps"
)
func main() {
type Config struct {
Host string `json:"host"`
}
var m = map[string]any{
"host": "localhost",
}
var c Config
err := maps.ToStruct(m, &c)
if err != nil {
panic(err)
}
fmt.Println(c.Host)
}
Output: localhost
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.