Answer the question
In order to leave comments, you need to log in
go. How to get the time zone by IP?
I rummaged through the geoip libraries, did not find what I needed.
Answer the question
In order to leave comments, you need to log in
https://github.com/oschwald/geoip2-golang - reads MaxMind databases ( GeoLite2 , GeoIP2 )
(ahtung, error handling is omitted in the example)
db, err := geoip2.Open("GeoIP2-City.mmdb")
ip := net.ParseIP("81.2.69.142")
record, err := db.City(ip)
fmt.Printf("Russian country name: %v\n", record.Country.Names["ru"])
fmt.Printf("Time zone: %v\n", record.Location.TimeZone)
// Output:
// Russian country name: Великобритания
// Time zone: Europe/London
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question