go-leveldb

go-leveldb is a Go wrapper for LevelDB
Building
You can run make
to build this library. It will download and compile
leveldb
and snappy
, then compile go-leveldb
.
Alternatively, if you have installed libleveldb-dev
on your machine, you can
use go build
to compile go-leveldb
. However, if libleveldb-dev
is
installed in non-standard folders, you must set CGO_CFLAGS
and CGO_LDFLAGS
such that cgo
knows the location of libleveldb-dev
.
Usage
go-leveldb supports most functions of leveldb's C API, except those passing
function pointers to the API.
Example code:
import "github.com/ccding/go-leveldb/leveldb"
// creates a database
db, err := leveldb.Open(dir, nil)
// put and get
err = db.Put([]byte("foo"), []byte("bar"), nil)
val, err := db.Get([]byte("foo"), nil) // returns "bar"
// closes the database
db.Close()
// deletes the database directory
err = leveldb.DestroyDB(dir, nil)
More details, please go to main.go
and GoDoc
TODO
Write tests and comments