2
0

Add bytea

This commit is contained in:
Jack Christensen
2017-03-09 21:07:40 -06:00
parent fa36ad9196
commit bac4af13bb
4 changed files with 255 additions and 0 deletions
+21
View File
@@ -85,6 +85,27 @@ func underlyingBoolType(val interface{}) (interface{}, bool) {
return nil, false
}
// underlyingBytesType gets the underlying type that can be converted to []byte
func underlyingBytesType(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.Slice:
if refVal.Type().Elem().Kind() == reflect.Uint8 {
convVal := refVal.Bytes()
return convVal, reflect.TypeOf(convVal) != refVal.Type()
}
}
return nil, false
}
// underlyingStringType gets the underlying type that can be converted to String
func underlyingStringType(val interface{}) (interface{}, bool) {
refVal := reflect.ValueOf(val)