-4

I have these two structs:

type CustomTime struct {
    time.Time
}

type Events struct {
    Timestamp CustomTime
}

When I reflect the field for Events.Timestamp, I get CustomTime; how can I get the actual underlying type which is time.Time?

1 Answers1

1

Here is a go playground example showing how you can access the anonymous field.

https://play.golang.org/p/yQULMVaQK0

Basically, once you have the value of the struct you should be able to get the Time value from field 0

Andy McCall
  • 446
  • 1
  • 4
  • 15