mercredi 11 septembre 2019

How to access a struct tag from inside a field-type in golang

I want to know if and how it is possible to access a struct tag set from a custom type used inside this struct.

type Out struct {
    C Custom `format:"asd"`
}

type Custom struct {
}

func (c Custom) GetTag() string {
    // somehow get access to `format:"asd"`
}

My goal is to be able to define a timeformat for un/marshaling and handle the actual time-unmarshalling parameterized by the structtag.

Thanks





Aucun commentaire:

Enregistrer un commentaire