go playground
As shown in the code above, one can use json:\",omitempty\" to omit certain fields in a struct to appear in json.
json:\",omitempty\"
For example
Easy way
type struct { < varname > < vartype > \`json : -\` }
Example :
type Boy struct { name string \`json : -\` }
this way on marshaling name will not get serialized.
name