func NewFile(filename string, offset int64, length int) (*File, error) {
	logger.Debugf("Will try to map new %s, %d, %d", filename, offset, length)
	f, err := os.Create(filename)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	_, err = f.Seek(int64(length-1), 0)
	if err != nil {
		log.Fatal(err)
	}
	_, err = f.Write([]byte("\000"))
	if err != nil {
		log.Fatal(err)
	}
	mmap, err := doMap(f, offset, length)
	logger.Debugf("Mapped a new file @%v for %d", mmap.mmap, mmap.size)
	return mmap, err
}
NewFile is a factory method to create a new memory mapped file with the specified capacity
package memmap
import (
	"errors"
	"fmt"
	"log"
	"os"
	"sync"
	"syscall"
	"unsafe"
	mapper "github.com/edsrzf/mmap-go"
	"github.com/op/go-logging"
)
type File struct {
	mmap unsafe.Pointer
	size int
}
var logger = logging.MustGetLogger("memmap")
var memories = sync.Map{}
func GetFileSize(filename string) int64 {
	file, err := os.Open(filename)
	if err != nil {
		logger.Error(err)
		return -1
	}
	defer file.Close()
	fi, err := file.Stat()
	if err != nil {
		logger.Fatal(err)
		return -1
	}
	return fi.Size()
}
func MapExisting(filename string, offset int64, length int) (*File, error) {
	logger.Debugf("Will try to map existing %s, %d, %d", filename, offset, length)
	f, err := os.OpenFile(filename, syscall.O_RDWR, 0644)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	fi, err := f.Stat()
	if err != nil {
		return nil, err
	}
	size := fi.Size()
	if size == 0 {
		return nil, errors.New("zero size for existing file")
	}
	if size < 0 {
		return nil, fmt.Errorf("mmap: stat %q returned %d", filename, size)
	}
	if size != int64(size) {
		return nil, fmt.Errorf("mmap: file %q is too large", filename)
	}
	var mapSize int
	if length != 0 {
		mapSize = length
	} else {
		mapSize = int(size)
	}
	logger.Debugf("Mapping existing file: fd: %d, size: %d, offset: %d", f.Fd(), size, offset)
	mmap, err := doMap(f, offset, mapSize)
	logger.Debugf("Mapped existing file @%v for %d", mmap.mmap, mmap.size)
	return mmap, err
}