oschwald / maxminddb-golang

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

Replace `unix.Mmap` with `syscall.Mmap`? #44

Closed jcrussell closed 6 years ago

jcrussell commented 6 years ago

Is there a reason to use golang.org/x/sys/unix.Mmap instead of syscall.Mmap? I swapped the Mmap and Munmap calls to syscall and they seemed to work fine.

This removes the golang.org/x/sys/unix dependency:

--- a/github.com/oschwald/maxminddb-golang/mmap_unix.go
+++ b/github.com/oschwald/maxminddb-golang/mmap_unix.go
@@ -4,14 +4,12 @@ package maxminddb

 import (
        "syscall"
-
-       "golang.org/x/sys/unix"
 )

 func mmap(fd int, length int) (data []byte, err error) {
-       return unix.Mmap(fd, 0, length, syscall.PROT_READ, syscall.MAP_SHARED)
+       return syscall.Mmap(fd, 0, length, syscall.PROT_READ, syscall.MAP_SHARED)
 }

 func munmap(b []byte) (err error) {
-       return unix.Munmap(b)
+       return syscall.Munmap(b)
 }

I can create a PR if you'd like.

oschwald commented 6 years ago

This was changed to not use syscall in https://github.com/oschwald/maxminddb-golang/commit/db462e096565fcf221d34a6506782289b9bf7085. The reason for the change is that syscall is no longer actively developed and external users of it were asked to switch to golang.org/x/sys. See this document for more information.

jcrussell commented 6 years ago

Hadn't heard about syscall being deprecated -- thanks for the pointer.