I have a structure that looks like this
type MediaFile struct {
ID string `json:"id"`
Secret string `json:"-"`
Title string `json:"title"`
}
I want to be able to change the script tag for Secret into json:"secret"
when a condition is satisfied.
The struct MediaFile has been referenced a lot within other parts of the code, so using a different Struct with a different name isn't feasible.
I tried to use pointers like follows. Note that I have removed the definition of struct Mediafile as seen before in the following example.
type AlterMediaFile struct {
ID string `json:"id"`
Secret string `json:"secret"`
Title string `json:"title"`
}
type MediaFile struct {
*AlterMediaFile
}
But it resulted in me receiving a lot of promoted field errors since it's AlterMediaFile is basically just a nested class of MediaFile in this case.
So, is there any simple way for me to be able to alter the 'Secret' script tag from json:"-"
to json:"secret"
?