I have a struct defined in fruits.go
package domain
type AppleImages struct {
Front string `json:"frontImage"`
Back string `json:"backImage"`
Top string `json:"topImage"`
}
And I defined the same in process.go (which returns this data to the handler). This definition is only for demonstration purposes since I'm getting values from the database using gorm so we cannot append the required URL here.
package process
func getApple() (apple domain.Apple){
apple = domain.Apple{
Front: "front-image.png"
Back: "back-image.png"
Top: "top-image.png"
}
return
}
For my output is want to return
{
frontImage: "https://www.example.com/front-image.png",
backImage: "https://www.example.com/back-image.png",
topImage: "https://www.example.com/top-image.png",
}
I don't want to manually add https://www.example.com/ to each of the images in the struct.
Is there a way of parsing through the struct and automatically appending this string to all existing values?