levigo is a Go wrapper for LevelDB
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples gofmt comparator_example.go Oct 31, 2012
.gitignore Adding *.out and _testmain.go to .gitignore. Jan 16, 2012
LICENSE MIT license Mar 26, 2012
README.md
batch.go Merge branch 'master' of github.com:jmhodges/levigo Oct 27, 2012
cache.go remove levigo.h to avoid user confusion Oct 27, 2012
comparator.go remove levigo.h to avoid user confusion Oct 27, 2012
conv.go remove levigo.h to avoid user confusion Oct 27, 2012
db.go Document the behavior of closed + -race Aug 4, 2015
doc.go
env.go remove levigo.h to avoid user confusion Oct 27, 2012
filterpolicy.go remove levigo.h to avoid user confusion Oct 27, 2012
iterator.go Fix iterator example usage to not crash Oct 6, 2014
leveldb_test.go sync writes for accurate tests Sep 30, 2014
options.go Clean up minor grammar and spelling errors. Feb 15, 2015
version.go

README.md

levigo

levigo is a Go wrapper for LevelDB.

The API has been godoc'ed and is available on the web.

Questions answered at golang-nuts@googlegroups.com.

Building

You'll need the shared library build of LevelDB installed on your machine. The current LevelDB will build it by default.

The minimum version of LevelDB required is currently 1.7. If you require the use of an older version of LevelDB, see the fork of levigo for LevelDB 1.4. Prefer putting in the work to be up to date as LevelDB moves very quickly.

Now, if you build LevelDB and put the shared library and headers in one of the standard places for your OS, you'll be able to simply run:

go get github.com/jmhodges/levigo

But, suppose you put the shared LevelDB library somewhere weird like /path/to/lib and the headers were installed in /path/to/include. To install levigo remotely, you'll run:

CGO_CFLAGS="-I/path/to/leveldb/include" CGO_LDFLAGS="-L/path/to/leveldb/lib" go get github.com/jmhodges/levigo

and there you go.

In order to build with snappy, you'll have to explicitly add "-lsnappy" to the CGO_LDFLAGS. Supposing that both snappy and leveldb are in weird places, you'll run something like:

CGO_CFLAGS="-I/path/to/leveldb/include -I/path/to/snappy/include"
CGO_LDFLAGS="-L/path/to/leveldb/lib -L/path/to/snappy/lib -lsnappy" go get github.com/jmhodges/levigo

(and make sure the -lsnappy is after the snappy library path!).

Of course, these same rules apply when doing go build, as well.

Caveats

Comparators and WriteBatch iterators must be written in C in your own library. This seems like a pain in the ass, but remember that you'll have the LevelDB C API available to your in your client package when you import levigo.

An example of writing your own Comparator can be found in https://github.com/jmhodges/levigo/blob/master/examples.