2
0

Add text to pgtype

This commit is contained in:
Jack Christensen
2017-03-04 21:20:56 -06:00
parent b1fc8109db
commit fa57904d6b
25 changed files with 768 additions and 149 deletions
+19
View File
@@ -85,6 +85,25 @@ func underlyingBoolType(val interface{}) (interface{}, bool) {
return nil, false
}
// underlyingStringType gets the underlying type that can be converted to String
func underlyingStringType(val interface{}) (interface{}, bool) {
refVal := reflect.ValueOf(val)
switch refVal.Kind() {
case reflect.Ptr:
if refVal.IsNil() {
return nil, false
}
convVal := refVal.Elem().Interface()
return convVal, true
case reflect.String:
convVal := refVal.String()
return convVal, reflect.TypeOf(convVal) != refVal.Type()
}
return nil, false
}
// underlyingPtrType dereferences a pointer
func underlyingPtrType(val interface{}) (interface{}, bool) {
refVal := reflect.ValueOf(val)