The problem that go returns json

When

go returns a json string, is it true that only fields with uppercase or all uppercase letters in the structure will be returned?

    type User struct {
        Id   int
        Name string
        sex string
    }
    me := User{Id: 12, Name: "",sex: ""}
    //json
    this.Data["json"] = &me
    this.ServeJSON()

the lowercase sex here will not be returned. Is this a characteristic of go?

{
Id: 12,
Name: ""
}
Dec.31,2021

Yes, the go language states that only identifiers that begin with uppercase letters are export. So other modules cannot access private variables in this structure


Yes, go starts with uppercase and lowercase letters to distinguish between public and private. If you convert lowercase to json, you can go like this:

type User struct {
        Id   int `json:"id"`
        Name string `json:"name"`
        Sex string `json:"sex"`
    }
Menu