Hi everybody !
I want to create a new entity (a Group) from results of an API (Vault) that returns JSON :
package services
// Get will fetch the group based on given params
func (gs *GroupService) Get(path string) (*domains.GroupEntity, error) {
secret, err := gs.vaultClient.Logical().Read(path)
if err != nil {return nil, err}
if secret == nil {return nil, nil}
return domains.NewGroupEntityFromJson(secret.Data)
}
Since I don't want to repeat the code of converting it, I created a method in my domains alongside my Group that does this conversion :
package domains
import "encoding/json"
type GroupEntity struct {
ID string `json:"id"`
}
func NewGroupEntityFromJson