10000 GitHub - ijt/filemap: Maps on the file system in Go
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ijt/filemap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

filemap

Maps on the file system

GitHub Workflow Status Go Report Card

If you have a big map that's forcing you to run your Go program on an expensive instance with lots of RAM, filemap may be for you.

Example:

package main

import (
	"bytes"
	"io/ioutil"
	"log"

	"github.com/ijt/filemap"
)

func main() {
	d, err := ioutil.TempDir("", "")
	if err != nil {
		log.Fatal(err)
	}
	m := filemap.New(d)
	k := "hello"
	v := []byte("world")
	if err := m.Set(k, v); err != nil {
		log.Fatal(err)
	}
	if !m.Has(k) {
		log.Fatal("map does not contain key after it was set")
	}
	v2, err := m.Get(k)
	if err != nil {
		log.Fatal(err)
	}
	if !bytes.Equal(v2, v) {
		log.Fatalf("Get returned %s, want %s", v2, v)
	}
}

Testing

make test

Benchmarking

make bench

About

Maps on the file system in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0