Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module github.com/wajeht/ip

go 1.26.0

require github.com/oschwald/geoip2-golang v1.13.0
require github.com/oschwald/geoip2-golang/v2 v2.1.0

require (
github.com/oschwald/maxminddb-golang v1.13.0 // indirect
golang.org/x/sys v0.20.0 // indirect
github.com/oschwald/maxminddb-golang/v2 v2.1.1 // indirect
golang.org/x/sys v0.38.0 // indirect
)
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/oschwald/geoip2-golang v1.13.0 h1:Q44/Ldc703pasJeP5V9+aFSZFmBN7DKHbNsSFzQATJI=
github.com/oschwald/geoip2-golang v1.13.0/go.mod h1:P9zG+54KPEFOliZ29i7SeYZ/GM6tfEL+rgSn03hYuUo=
github.com/oschwald/maxminddb-golang v1.13.0 h1:R8xBorY71s84yO06NgTmQvqvTvlS/bnYZrrWX1MElnU=
github.com/oschwald/maxminddb-golang v1.13.0/go.mod h1:BU0z8BfFVhi1LQaonTwwGQlsHUEu9pWNdMfmq4ztm0o=
github.com/oschwald/geoip2-golang/v2 v2.1.0 h1:DjnLhNJu9WHwTrmoiQFvgmyJoczhdnm7LB23UBI2Amo=
github.com/oschwald/geoip2-golang/v2 v2.1.0/go.mod h1:qdVmcPgrTJ4q2eP9tHq/yldMTdp2VMr33uVdFbHBiBc=
github.com/oschwald/maxminddb-golang/v2 v2.1.1 h1:lA8FH0oOrM4u7mLvowq8IT6a3Q/qEnqRzLQn9eH5ojc=
github.com/oschwald/maxminddb-golang/v2 v2.1.1/go.mod h1:PLdx6PR+siSIoXqqy7C7r3SB3KZnhxWr1Dp6g0Hacl8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"syscall"
"time"

"github.com/oschwald/geoip2-golang"
"github.com/oschwald/geoip2-golang/v2"
"github.com/wajeht/ip/assets"
)

Expand Down Expand Up @@ -125,9 +125,9 @@
case json && geo:
response := fmt.Sprintf(`{"ip": "%s", "range": [%f, %f], "country": "%s", "region": "%s", "eu": %t, "timezone": "%s", "city": "%s", "ll": [%f, %f], "metro": %d, "area": %d}`,
ip, record.Location.Longitude, record.Location.Latitude,
record.Country.IsoCode, record.Subdivisions[0].IsoCode,

Check failure on line 128 in main.go

View workflow job for this annotation

GitHub Actions / Tests

record.Subdivisions[0].IsoCode undefined (type geoip2.CitySubdivision has no field or method IsoCode, but does have field ISOCode)

Check failure on line 128 in main.go

View workflow job for this annotation

GitHub Actions / Tests

record.Country.IsoCode undefined (type geoip2.CountryRecord has no field or method IsoCode, but does have field ISOCode)
record.Country.IsInEuropeanUnion, record.Location.TimeZone,
record.City.Names["en"], record.Location.Longitude, record.Location.Latitude,

Check failure on line 130 in main.go

View workflow job for this annotation

GitHub Actions / Tests

cannot index record.City.Names (variable of struct type geoip2.Names)
record.Location.MetroCode, record.Location.AccuracyRadius)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
Expand All @@ -147,9 +147,9 @@

case geo:
formattedGeo := fmt.Sprintf(`<strong>IP:</strong> %s<br>`, ip)
formattedGeo += fmt.Sprintf(`<strong>Country:</strong> %s<br>`, record.Country.IsoCode)

Check failure on line 150 in main.go

View workflow job for this annotation

GitHub Actions / Tests

record.Country.IsoCode undefined (type geoip2.CountryRecord has no field or method IsoCode, but does have field ISOCode)
formattedGeo += fmt.Sprintf(`<strong>Region:</strong> %s<br>`, record.Subdivisions[0].IsoCode)

Check failure on line 151 in main.go

View workflow job for this annotation

GitHub Actions / Tests

record.Subdivisions[0].IsoCode undefined (type geoip2.CitySubdivision has no field or method IsoCode, but does have field ISOCode)
formattedGeo += fmt.Sprintf(`<strong>City:</strong> %s<br>`, record.City.Names["en"])

Check failure on line 152 in main.go

View workflow job for this annotation

GitHub Actions / Tests

cannot index record.City.Names (variable of struct type geoip2.Names)
formattedGeo += fmt.Sprintf(`<strong>Latitude:</strong> %f<br>`, record.Location.Latitude)
formattedGeo += fmt.Sprintf(`<strong>Longitude:</strong> %f<br>`, record.Location.Longitude)
formattedGeo += fmt.Sprintf(`<strong>Timezone:</strong> %s<br>`, record.Location.TimeZone)
Expand Down Expand Up @@ -222,7 +222,7 @@
return nil, fmt.Errorf("invalid IP address: %s", ipStr)
}

record, err := db.City(ip)

Check failure on line 225 in main.go

View workflow job for this annotation

GitHub Actions / Tests

cannot use ip (variable of slice type net.IP) as netip.Addr value in argument to db.City

if err != nil {
return nil, err
Expand Down
Loading