Contents
What is it?
The gommap project enables Go programs to directly work with memory mapped files and devices in a very efficient way.
The following blog post has some interesting details about how this was done:
API documentation
The API documentation is currently available at:
Example
Here is a very simple example which reads the first line out of /etc/passwd through mapped memory:
package main
import (
"launchpad.net/gommap"
"bytes"
"os"
)
func main() {
file, err := os.Open("/etc/passwd", os.O_RDONLY, 0)
if err == nil {
mmap, err := gommap.Map(file.Fd(), gommap.PROT_READ,
gommap.MAP_PRIVATE)
if err == nil {
end := bytes.Index(mmap, []byte("\n"))
println(string([]byte(mmap[:end])))
}
}
if err != nil {
println(err.String())
}
}
Source code
To obtain the source code, use Bazaar to download it from Launchpad:
$ bzr branch lp:gommap
Reporting bugs
Please report bugs at:
How to build and install gommap
Just use goinstall:
$ goinstall launchpad.net/gommap
License
gommap is made available under the simplified BSD license.
Contact
Gustavo Niemeyer <gustavo@niemeyer.net>