-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Migrate jackc/pgtype CIDR to its pgx/v5/pgtype alternative #1470
Copy link
Copy link
Closed
Description
I'm trying to migrate from pgx/v4 to pgx/v5 and in particular I need to rewrite code that uses CIDR type from jackc/pgtype to it's v5 alternative. I see v5/pgtype has the InetCodec type but I can't figure out how to use it instead of CIDR from v4.
Here the code I need to rewrite:
package main
import (
"net"
pgtypeV4 "github.com/jackc/pgtype" // TODO: Migrate to "github.com/jackc/pgx/v5/pgtype"
)
func toPgCIDRs(a []*net.IPNet) pgtypeV4.CIDRArray {
elements := make([]pgtypeV4.CIDR, len(a))
for i, e := range a {
elements[i] = pgtypeV4.CIDR(pgtypeV4.Inet{IPNet: e, Status: pgtypeV4.Present})
}
return pgtypeV4.CIDRArray{
Status: pgtypeV4.Present,
Elements: elements,
Dimensions: []pgtypeV4.ArrayDimension{{Length: int32(len(a)), LowerBound: 0}},
}
}
Any kind of help would be greatly appreciated!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels