What does this code mean?

clipboard.png

what is the meaning of the red box behind the structure of golang, recently?

Mar.05,2021

GOLANG struct tag


indicates that after the json formatted output, the field of UserId is user_id , which means that UserId can be renamed. The label of


golang, indicating that after the structure body is transformed into json, the corresponding field name of json is user_id.


I don't know what you think. Although it seems that tag makes the struct encoding / parsing of golang more flexible, it is actually disgusting to use, especially when you want to convert struct to json and xml, you have to add so much tag to each of your struct export attributes.

Menu