Skip to content

Commit 1162806

Browse files
authored
Implement CIDR.Value() to make it possible to send it to the database (#4)
Go doesn't inherit functions from its base type (unless you embed it in a struct, but that'd be a backwards incompatible change) so we need to explicitly implement .Value()
1 parent 20aff22 commit 1162806

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cidr.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package pqtype
22

3-
import "fmt"
3+
import (
4+
"database/sql/driver"
5+
"fmt"
6+
)
47

58
type CIDR Inet
69

@@ -31,3 +34,7 @@ func (dst *CIDR) Scan(src interface{}) error {
3134

3235
return fmt.Errorf("cannot scan %T", src)
3336
}
37+
38+
func (src CIDR) Value() (driver.Value, error) {
39+
return Inet(src).Value()
40+
}

0 commit comments

Comments
 (0)