You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
399 B
25 lines
399 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/mitchellh/mapstructure"
|
|
)
|
|
|
|
type People struct {
|
|
Name string `json:"name_title"`
|
|
Age int `json:"age_size"`
|
|
}
|
|
|
|
func main() {
|
|
mapInstance := make(map[string]interface{})
|
|
mapInstance["Name"] = "jqw"
|
|
mapInstance["Age"] = 18
|
|
|
|
var people People
|
|
err := mapstructure.Decode(mapInstance, &people)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
fmt.Println(people)
|
|
}
|