I have a struct such as this:
type Time struct {
Time time.Time
Valid bool
}
Now if I call reflect.ValueOf()
on a Time
struct initialized with, say time.Now()
and false
, I'll get the following results:
{2018-06-09 15:03:17.4320396 false}
Is there a way to alter the struct (add a method? rename the fields?) so that reflect
would only return the time.Time
value, but not the bool
one ?
Kind of like what the Valuer/Scanner interface does for SQL queries, but with reflect
.