我正在使用mitchellh/mapstructure映射从map[string]interface{}到struct
有没有办法告诉mapstructure转换string为uuid.UUID?
map[string]interface{}:
{
"id": "af7926b1-98eb-4c96-a2ba-7e429085b2ad",
"title": "new title",
}
struct
package entities
import (
"github.com/google/uuid"
)
type Post struct {
Id uuid.UUID `json:"id"`
Title string `json:"title"`
}
慕标5832272
相关分类