/maxminddb-golang-example

https://dou.ua/forums/topic/35195/

Primary LanguageGoMIT LicenseMIT

Приклад використання MaxMind в Go

https://dou.ua/forums/topic/35195/

Support Ukraine 🇺🇦

Structure

tree . -h
├── [4.0K]  GeoLite2-City_20230721
│   ├── [  55]  COPYRIGHT.txt
│   ├── [ 68M]  GeoLite2-City.mmdb
│   ├── [ 398]  LICENSE.txt
│   └── [ 116]  README.txt
├── [4.0K]  GeoLite2-Country_20230721
│   ├── [  55]  COPYRIGHT.txt
│   ├── [5.8M]  GeoLite2-Country.mmdb
│   └── [ 398]  LICENSE.txt
├── [ 33M]  GeoLite2-City_20230721.tar.gz
├── [3.0M]  GeoLite2-Country_20230721.tar.gz
├── [ 253]  go.mod
├── [ 881]  go.sum
├── [1.0K]  LICENSE
├── [ 155]  main_test.go
├── [ 525]  Makefile
└── [  91]  README.md

Testing

# make bench
go test ./... -v -bench=. -benchmem -benchtime=1000000x -count=10 > bench.txt
benchstat bench.txt
goos: linux
goarch: amd64
pkg: github.com/doutivity/maxminddb-golang-example
cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
BenchmarkLookupTurkey
BenchmarkLookupTurkey-12    	 1000000	      2370 ns/op	      34 B/op	       3 allocs/op
PASS
ok  	github.com/doutivity/maxminddb-golang-example	2.374s
name                            time/op
GeoLite2CountryLookupTurkey-12  2.75µs ± 4%
GeoLite2CityLookupTurkey-12     3.23µs ± 8%

name                            alloc/op
GeoLite2CountryLookupTurkey-12   34.0B ± 0%
GeoLite2CityLookupTurkey-12      34.0B ± 0%

name                            allocs/op
GeoLite2CountryLookupTurkey-12    3.00 ± 0%
GeoLite2CityLookupTurkey-12       3.00 ± 0%

Packages