Package Name: mapstructure

go get "github.com/mitchellh/mapstructure"

Example

package main

import (
	"fmt"
	"github.com/mitchellh/mapstructure"
)

type Person struct {
	Name   string            `json:"name"`
	Age    int               `json:"age"`
	Emails []string          `json:"emails"`
}

func structToMap() (err error){
	result := make(map[string]interface{})

	input := Person{
		Name:   "GG",
		Age:    11,
		Emails: []string{"123", "HHHH"},
	}
	var decoder *mapstructure.Decoder
	if decoder, err = mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", Result: &result}); err != nil {
		return
	} else if err = decoder.Decode(input); err != nil {
		return
	}
	fmt.Printf("%#v \n", result)
	return nil
}

func mapToStruct() (err error){
	input := map[string]interface{}{
		"name":   "yy",
		"age":    123,
		"emails": []string{"jj", "tt"},
	}

	result := Person{}

	var decoder *mapstructure.Decoder
	if decoder, err = mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", Result: &result}); err != nil {
		return
	} else if err = decoder.Decode(input); err != nil {
		return
	}
	fmt.Printf("%#v \n", result)
	return nil
}

func main() {
	fmt.Println("structToMap")
	_ = structToMap()
	fmt.Println("mapToStruct")
	_ = mapToStruct()
}

go playground