I used gorm library.
gorm support struct data inserting in DB and returning.
But my service do not always need every struct member.
For Example;
/Address => this api will return only user address.
But orm return all struct memeber.
like this.
type User {
Name string
Address string
}
db.find(&user)
apiResponse(200,user)
So I always make serializer code for specific api returning shape.
type Serializer {
Address string
}
func MakeSerializer(User u) Serializer {
return Serilizer { Address: u.Address }
}
But Above Code is not good.
Cause all most Api Return Shape is vary. So I will need enormous serilzer code.
Show me best practice for this problem.
Thank u