浏览文章

文章信息

Go语言结构体常识|Json返回结构体为空 13911

Go语言中结构体定义

type Student struct{
   Name string
   Age int
}

student := new(Student)
student.Name = "小明"
student.Age = 12

文中得到常识:Go规定,小写首字母为私有变量,大写字母是公开变量,所以,如果你在结构体中小写开头,那如果你写正在写json结构体数据返回的时候将空空。

原创