abh/geoip

Programs using this package won't build because of an error in geoip-demo.go

Bobobo-bo-Bo-bobo opened this issue · 0 comments

If a Go program uses this package and will be build using go install ./... it can't build because
of an type error in geoip-demo.go:

# github.com/abh/geoip/ex
src/github.com/abh/geoip/ex/geoip-demo.go:41:9: cannot use *gi (type geoip.GeoIP) as type *geoip.GeoIP in argument to test4
src/github.com/abh/geoip/ex/geoip-demo.go:42:9: cannot use *gi (type geoip.GeoIP) as type *geoip.GeoIP in argument to test4

This is caused by a wrong type in geoip-demo.go. geoip.Open returns a pointer to GeoIP structure and the function test4 in the geoip-demo.go file expects a pointer but the main function passes the structure instead of the pointer.

This patch will fix this issue:

--- ex/geoip-demo.go.original	2020-06-06 11:24:57.841432573 +0200
+++ ex/geoip-demo.go	2020-06-06 11:25:04.749461347 +0200
@@ -38,8 +38,8 @@
 	}
 
 	if gi != nil {
-		test4(*gi, "207.171.7.51")
-		test4(*gi, "127.0.0.1")
+		test4(gi, "207.171.7.51")
+		test4(gi, "127.0.0.1")
 	}
 	if gi6 != nil {
 		ip := "2607:f238:2::5"