package json
import jsoniter "github.com/json-iterator/go"
var (
json = jsoniter.ConfigCompatibleWithStandardLibrary
// Marshal is exported by vin/json package.
Marshal = json.Marshal
// Unmarshal is exported by vin/json package.
Unmarshal = json.Unmarshal
// MarshalIndent is exported by vin/json package.
MarshalIndent = json.MarshalIndent
// NewDecoder is exported by vin/json package.
NewDecoder = json.NewDecoder
// NewEncoder is exported by vin/json package.
NewEncoder = json.NewEncoder
)
实际使用
cmd := new(model.SendTextMailCommand)
//将json数据反序列到cmd中
jsoniter.Unmarshal(msg.Data, cmd)
[译] 使用 VSCode 调试 Golang - 掘金