From dca616f3750b70bd4a5bb951c3277262d39c51d9 Mon Sep 17 00:00:00 2001 From: Jille Timmermans Date: Wed, 11 May 2022 17:08:00 +0200 Subject: [PATCH] Implement CIDR.Value() to make it possible to send it to the database 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() --- cidr.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cidr.go b/cidr.go index 0181a97..a106008 100644 --- a/cidr.go +++ b/cidr.go @@ -1,6 +1,9 @@ package pqtype -import "fmt" +import ( + "database/sql/driver" + "fmt" +) type CIDR Inet @@ -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() +}