package
0.0.0-20161202185726-98eddf990150
Repository: https://github.com/hellbutcher/go-mmstruct.git
Documentation: pkg.go.dev
# README
go-mmstruct / mmf 
working with memory mapped files in golang.
Installation
Go and get it...
$ go get github.com/HellButcher/go-mmstruct/mmf
Usage
Creating a file:
package main
import (
"github.com/HellButcher/go-mmstruct/mmf"
)
func main() {
mf, err := mmf.CreateMappedFile("aNewFile.bin", 4096)
if err != nil {
// ...
}
defer mf.Close()
// do something in the mapped memory area
data := mf.Bytes()
data[1337] = 42 // writing
foo := data[666] // reading
}
Opening a file:
package main
import (
"github.com/HellButcher/go-mmstruct/mmf"
)
func main() {
mf, err := mmf.OpenMappedFile("anExistingFile.bin")
if err != nil {
// ...
}
defer mf.Close()
// do something in the mapped memory area
data := mf.Bytes()
data[666] = 42 // writing
foo := data[1337] // reading
}
The MappedFile
object can also be used as a Reader
or
Writer
(and some other interfaces).