Skip to content

Commit

Permalink
add a func to get the version of the loaded leveldb
Browse files Browse the repository at this point in the history
  • Loading branch information
jvshahid committed Apr 2, 2014
1 parent 251e8f0 commit f5f59b3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You'll need the shared library build of
[LevelDB](http://code.google.com/p/leveldb/) installed on your machine. The
current LevelDB will build it by default.

The minimum version of LevelDB required is currently 1.6. If you require the
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](https://github.com/jmhodges/levigo_leveldb_1.4). Prefer putting in the
work to be up to date as LevelDB moves very quickly.
Expand Down
4 changes: 4 additions & 0 deletions leveldb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ func init() {

// This testcase is a port of leveldb's c_test.c.
func TestC(t *testing.T) {
if GetLevelDBMajorVersion() <= 0 {
t.Errorf("Major version cannot be less than zero")
}

dbname := tempDir(t)
defer deleteDBDirectory(t, dbname)
env := NewDefaultEnv()
Expand Down
15 changes: 15 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package levigo

/*
#cgo LDFLAGS: -lleveldb
#include "leveldb/c.h"
*/
import "C"

func GetLevelDBMajorVersion() int {
return int(C.leveldb_major_version())
}

func GetLevelDBMinorVersion() int {
return int(C.leveldb_minor_version())
}

0 comments on commit f5f59b3

Please sign in to comment.