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旁边的单引号。


原文地址:https://www.cnblogs.com/l1ng14/p/13908666.html