From 9e0c065eccc097e8fbf826875e3a1f55608be639 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 11 Apr 2026 17:21:39 +0500 Subject: [PATCH] Replace `ErrNotFound` constant with `errors.New` for consistent error handling --- geoip2.go | 3 ++- service/maxmind/mmdb/city.go | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/geoip2.go b/geoip2.go index 69a805c..3739f39 100644 --- a/geoip2.go +++ b/geoip2.go @@ -2,13 +2,14 @@ package geoip2 import ( "context" + "errors" "fmt" "net/netip" "strings" ) // ErrNotFound is returned when the database does not contain the IP address. -const ErrNotFound = "not found" +var ErrNotFound = errors.New("not found") // Info is a structure that contains information about the IP address. type Info struct { diff --git a/service/maxmind/mmdb/city.go b/service/maxmind/mmdb/city.go index 37907b2..04d5f89 100644 --- a/service/maxmind/mmdb/city.go +++ b/service/maxmind/mmdb/city.go @@ -1,7 +1,6 @@ package mmdb import ( - "errors" "net/netip" "git.kor-elf.net/kor-elf-shield/geoip2" @@ -47,7 +46,7 @@ func (c *City) infoCity(ip netip.Addr, reader *oschwaldGeoip2.Reader) (geoip2.In return geoip2.Info{}, err } if !record.HasData() { - return geoip2.Info{}, errors.New(geoip2.ErrNotFound) + return geoip2.Info{}, geoip2.ErrNotFound } var timeZone string -- 2.52.0