2 Commits

3 changed files with 14 additions and 14 deletions
+2 -1
View File
@@ -2,13 +2,14 @@ package geoip2
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"net/netip" "net/netip"
"strings" "strings"
) )
// ErrNotFound is returned when the database does not contain the IP address. // 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. // Info is a structure that contains information about the IP address.
type Info struct { type Info struct {
+3 -4
View File
@@ -1,7 +1,6 @@
package mmdb package mmdb
import ( import (
"errors"
"net/netip" "net/netip"
"git.kor-elf.net/kor-elf-shield/geoip2" "git.kor-elf.net/kor-elf-shield/geoip2"
@@ -19,7 +18,7 @@ const (
// City is a structure that contains information about the IP address. // City is a structure that contains information about the IP address.
type City struct { type City struct {
// lang is a language. // lang is a language.
lang language lang Language
} }
// NewCity creates a new City instance. // NewCity creates a new City instance.
@@ -27,7 +26,7 @@ type City struct {
// @param logger - a logger // @param logger - a logger
// @param dir - a directory for storing MaxMind GeoIP2 database // @param dir - a directory for storing MaxMind GeoIP2 database
// @return geoip2.RefreshableGeoIP2 - a MaxMind GeoIP2 database service // @return geoip2.RefreshableGeoIP2 - a MaxMind GeoIP2 database service
func NewCity(download *Download, logger geoip2.Logger, dir string, language language) geoip2.RefreshableGeoIP2 { func NewCity(download *Download, logger geoip2.Logger, dir string, language Language) geoip2.RefreshableGeoIP2 {
city := &City{ city := &City{
lang: language, lang: language,
} }
@@ -47,7 +46,7 @@ func (c *City) infoCity(ip netip.Addr, reader *oschwaldGeoip2.Reader) (geoip2.In
return geoip2.Info{}, err return geoip2.Info{}, err
} }
if !record.HasData() { if !record.HasData() {
return geoip2.Info{}, errors.New(geoip2.ErrNotFound) return geoip2.Info{}, geoip2.ErrNotFound
} }
var timeZone string var timeZone string
+9 -9
View File
@@ -1,15 +1,15 @@
package mmdb package mmdb
type language string type Language string
const ( const (
LanguageRussian = language("Russian") LanguageRussian = Language("Russian")
LanguageEnglish = language("English") LanguageEnglish = Language("English")
LanguageSpanish = language("Spanish") LanguageSpanish = Language("Spanish")
LanguageFrench = language("French") LanguageFrench = Language("French")
LanguageGerman = language("German") LanguageGerman = Language("German")
LanguageJapanese = language("Japanese") LanguageJapanese = Language("Japanese")
LanguageBrazilianPortuguese = language("BrazilianPortuguese") LanguageBrazilianPortuguese = Language("BrazilianPortuguese")
LanguageSimplifiedChinese = language("SimplifiedChinese") LanguageSimplifiedChinese = Language("SimplifiedChinese")
) )