1 This is an implementation of the [LevelDB key/value database](http:code.google.com/p/leveldb) in the [Go programming language](http:golang.org).
3 [![Build Status](https://travis-ci.org/syndtr/goleveldb.png?branch=master)](https://travis-ci.org/syndtr/goleveldb)
8 go get github.com/syndtr/goleveldb/leveldb
13 * Need at least `go1.4` or newer.
18 Create or open a database:
20 // The returned DB instance is safe for concurrent use. Which mean that all
21 // DB's methods may be called concurrently from multiple goroutine.
22 db, err := leveldb.OpenFile("path/to/db", nil)
27 Read or modify the database content:
29 // Remember that the contents of the returned slice should not be modified.
30 data, err := db.Get([]byte("key"), nil)
32 err = db.Put([]byte("key"), []byte("value"), nil)
34 err = db.Delete([]byte("key"), nil)
38 Iterate over database content:
40 iter := db.NewIterator(nil, nil)
42 // Remember that the contents of the returned slice should not be modified, and
43 // only valid until the next call to Next.
54 iter := db.NewIterator(nil, nil)
55 for ok := iter.Seek(key); ok; ok = iter.Next() {
63 Iterate over subset of database content:
65 iter := db.NewIterator(&util.Range{Start: []byte("foo"), Limit: []byte("xoo")}, nil)
74 Iterate over subset of database content with a particular prefix:
76 iter := db.NewIterator(util.BytesPrefix([]byte("foo-")), nil)
87 batch := new(leveldb.Batch)
88 batch.Put([]byte("foo"), []byte("value"))
89 batch.Put([]byte("bar"), []byte("another value"))
90 batch.Delete([]byte("baz"))
91 err = db.Write(batch, nil)
97 Filter: filter.NewBloomFilter(10),
99 db, err := leveldb.OpenFile("path/to/db", o)
107 You can read package documentation [here](http:godoc.org/github.com/syndtr/goleveldb).