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:


Here is a very simple example which reads the first line out of /etc/passwd through mapped memory:

package main

import (

func main() {
    file, err := os.Open("/etc/passwd", os.O_RDONLY, 0)
    if err == nil {
        mmap, err := gommap.Map(file.Fd(), gommap.PROT_READ,
        if err == nil {
            end := bytes.Index(mmap, []byte("\n"))
    if err != nil {

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


gommap is made available under the simplified BSD license.


Gustavo Niemeyer <gustavo@niemeyer.net>

gommap (last edited 2011-02-18 08:29:17 by GustavoNiemeyer)