Skip to content

proposal: support for net/netip types #88

Closed
@ainar-g

Description

@ainar-g

Go 1.18 includes the new net/netip package with value types related to IP addresses and networks.

Perhaps, new methods should be added, for example Reader.LookupAddr(ip netip.Addr, result any) and Reader.Prefixes with a corresponding iterator, that would encourage the use of the new IP types. I think, it could also reduce some of the boilerplate such as:

maxminddb-golang/reader.go

Lines 247 to 250 in ccd731c

ipV4Address := ip.To4()
if ipV4Address != nil {
ip = ipV4Address
}

and a lot of len(ip) == net.IPv4len and ip.To4() == nil.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions