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
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ Country](http://www.maxmind.com/app/geoip_country) database or you can
country := gi6.GetCountry_v6("2607:f238:2::5")
fmt.Println(country)

## build

###windows use MSYS/MSYS2

1. build libGeoIP (geoip-api-c)

see https://github.com/maxmind/geoip-api-c/releases page
download latest version
tar xvf ...

./configure --disable-shared --disable-dependency-tracking --disable-data-files CFLAGS=-D_WIN32_WINNT=0x0501

`CFLAGS=-D_WIN32_WINNT=0x0501` enable link winsock2 `ws32`
without this will show build error :

Undefined reference to getaddrinfo
...


2. build(install) geoip static

CGO_ENABLED=1 GOOS=windows CGO_CFLAGS=-I/usr/local/include CGO_LDFLAGS='-L/usr/local/lib -lGeoIP -lwsock32 -lws2_32' go install -x --ldflags '-extldflags "-static"' github.com/chennqqi/geoip


github.com/chennqqi/geoip or source repo github.com/abh/geoip

my MSYS don't contain `pkg-config`, so i comment it in geoip.go


## Contact

Expand Down
2 changes: 1 addition & 1 deletion geoip.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package geoip

/*
#cgo pkg-config: geoip
//#cgo pkg-config: geoip
#include <stdio.h>
#include <errno.h>
#include <GeoIP.h>
Expand Down