Declaring a name next to the field

What does this notation mean when we declare some name next to the field?

type Poet struct {
    PS string `name:"testString"`

How to use it?

This is for example used to declare how the elements of a JSON object map to the struct members.


json:"key" you send key as key


json:"KeY" you send key as KeY


json:"KeY,omitempty" you send key as KeY, but is the value empty, it is not considered.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.