oschwald / maxminddb-golang

MaxMind DB Reader for Go
ISC License
597 stars 101 forks source link

Avoiding dependency on golang.org/x/sys #46

Closed tonyghita closed 6 years ago

tonyghita commented 6 years ago

Hey @oschwald, thanks for the excellent library. I'm hoping to get your thoughts on how we could re-organize the code so that the golang.org/x/sys dependency is not pulled if when it won't be used.

I found the performance between the memory-mapped approach and the FromBytes approach to reading the country database to be negligible.

For simplicity, I'd like to avoid the memory-mapping (and it's associated dependencies in golang.org/x/sys) . The extra dependency on functionality which won't be used is pretty heavy—golang.org/x/sys/unix adds ~160K lines of code that I must vendor in my application.

oschwald commented 6 years ago

Thanks for the suggestion. I don't plan on removing memory mapping. Some databases are gigabytes in size and it would very expensive to load them in memory. If you want to avoid memory mapping and golang.org/x/sys, you could build with the appengine build tag, which uses this implementation of Open.

tonyghita commented 6 years ago

That makes sense 👍In case anyone else comes across this: I'm only using the ~3.6MB country database file, so I'll run the fork from my account to avoid the extra dependency for my specific usecase.