From a snippet (not comprehensively functional here):
type SomeType struct {
UserEmail sql.NullString `db:"user_email"`
RecID sql.NullInt64 `db:"rec_id"`
}
for g := 0; g < s.NumField(); g++ {
f := s.Field(g)
tType = f.Type().String()
tType = strings.Replace(tType, `sql.Null`, ``, 1)
tType = strings.Replace(tType, `mysql.Null`, ``, 1)
tType = strings.Replace(tType, `decimal.NullDecimal`, `Decimal`, 1)
tType = strings.Replace(tType, `myTime`, `Time`, 1)
fmt.Println(g, typeOfT.Field(g).Name, tType, f)
}
For normal output, I write UserEmail.String. If the .String is absent, then the output is:
UserEmail String {johndoe@somecompany.com true}
How would I dynamically append the .String, or .Int64, depending on the data type, wherein that type extention actually functions to produce:
UserEmail String johndoe@somecompany.com
Essentially turning the strings "UserEmail" and "String" into UserEmail.String
Thanks!