Golang 序列化给字段起别名(field tag must be a string)

Go-序列化给字段起别名(field tag must be a string)

type Student struct {
	Name string	`json:"name"`  // 是 ` ` (tab键上的~按键) ,不是 ' '
	Sex string `json:"sex"`
	Age int `json:"age"`
	Sal float64 `json:"sal"`
}

编译错误field tag must be a string,后来发现是后面标签上引号不正确,不应该是回车键旁边的单引号,而是数字键1旁边的单引号。


posted @ 2020-11-01 09:59  L1ng14  阅读(486)  评论(0编辑  收藏  举报