mardi 30 octobre 2018

golang - print tag for slice of struct within a struct

I have struct Config which consist of Field SliceOfAnotherStruct which contained the slice of pointer to AnotherStruct.

Here how could I get the json tag for field Bank in AnotherStruct.

type Config struct {
    SliceOfAnotherStruct         []*AnotherStruct        `bson:"anotherStruct" json:"anotherStruct" validate:"required,dive,required"`
}

type AnotherStruct struct {
    Name                   string        `bson:"name" json:"name" validate:"required"`
    Cost                   string        `bson:"cost" json:"cost" validate:"required"`
    Bank    string        `bson:"bank" json:"bank" validate:"required"`
    IFSC     string        `bson:"ifsc" json:"ifsc" validate:"required"`
}





Aucun commentaire:

Enregistrer un commentaire