Struct field with reserved name golang

Hi Im doing an API client and I want to use a struct to pull out the json, the problem is that one of the json fields should be named type, as far as I know it is a reserved keyword, how can I create a struct with a “type” field in it?


What I want to do:

type Card struct {
  cardId  string
  name    string
  cardSet string
  type    string

That won't work to begin with, since you're not exporting the fields names.

Otherwise, you can use struct tags to name the json fields as you need

type Card struct {
    CardID  string `json:"cardId"`
    Name    string `json:"name"`
    CardSet string `json:"cardSet"`
    Type    string `json:"type"`