Skip to content

Commit

Permalink
Merge pull request #22 from jamiri/add-support-for-sql-nullstring
Browse files Browse the repository at this point in the history
Add support for sql.NullString
  • Loading branch information
leebenson authored Apr 22, 2020
2 parents 4c55492 + 8e3ba2d commit 8fa7c15
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion conform.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,14 @@ func Strings(iface interface{}) error {
}
case reflect.Struct:
if el.CanAddr() && el.Addr().CanInterface() {
Strings(el.Addr().Interface())
// To handle "sql.NullString" we can assume that tags are added to a field of type struct rather than string
if tags := v.Tag.Get("conform"); tags != "" && el.CanSet() {
field := el.FieldByName("String")
str := field.String()
field.SetString(transformString(str, tags))
} else {
Strings(el.Addr().Interface())
}
}
case reflect.String:
if el.CanSet() {
Expand Down

0 comments on commit 8fa7c15

Please sign in to comment.