2
0

Expand pgtype.Value interface

- Include and rename ConvertFrom to Set
- Add Get
- Include AssignTo
This commit is contained in:
Jack Christensen
2017-03-11 19:53:02 -06:00
parent 542eac08c6
commit 57494a6a0f
74 changed files with 568 additions and 185 deletions
+13 -2
View File
@@ -11,7 +11,7 @@ type Text struct {
Status Status
}
func (dst *Text) ConvertFrom(src interface{}) error {
func (dst *Text) Set(src interface{}) error {
switch value := src.(type) {
case Text:
*dst = value
@@ -25,7 +25,7 @@ func (dst *Text) ConvertFrom(src interface{}) error {
}
default:
if originalSrc, ok := underlyingStringType(src); ok {
return dst.ConvertFrom(originalSrc)
return dst.Set(originalSrc)
}
return fmt.Errorf("cannot convert %v to Text", value)
}
@@ -33,6 +33,17 @@ func (dst *Text) ConvertFrom(src interface{}) error {
return nil
}
func (dst *Text) Get() interface{} {
switch dst.Status {
case Present:
return dst.String
case Null:
return nil
default:
return dst.Status
}
}
func (src *Text) AssignTo(dst interface{}) error {
switch v := dst.(type) {
case *string: