"type" is a language keyword but I need to use it as an attribute name in my structure like :
type Message struct{
type string
}
My IDE finds an error line 2
"type" is a language keyword but I need to use it as an attribute name in my structure like :
type Message struct{
type string
}
My IDE finds an error line 2
Why do you need to use type
?
When you need to parse JSON-encoded data with this attribute, you can write the following:
type Message struct {
Kind string `json:"type"`
}