Skip to content

Commit

Permalink
Implement CIDR.Value() to make it possible to send it to the database (
Browse files Browse the repository at this point in the history
…#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()
  • Loading branch information
Jille authored Sep 26, 2023
1 parent 20aff22 commit 1162806
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cidr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package pqtype

import "fmt"
import (
"database/sql/driver"
"fmt"
)

type CIDR Inet

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

return fmt.Errorf("cannot scan %T", src)
}

func (src CIDR) Value() (driver.Value, error) {
return Inet(src).Value()
}

0 comments on commit 1162806

Please sign in to comment.