How to use LevelDB in go?

From http://code.google.com/p/leveldb/ , it seems not explicit or easy to use LevelDB with Go. But I really want to know how to use it in Go.

Can someone give me a hint?

+6
source share
3 answers

Use leveldb-go ported by Go authors.

+2
source

Use the levigo Golang shell around the C + LevelDB version.

The levigo / leveldb_test.go file gives you an example of using levigo.

+11
source

Here is an implementation of Go LevelDB https://github.com/syndtr/goleveldb

Here's how to use it:

go get github.com/syndtr/goleveldb/leveldb 

Create or open a database:

 db, err := leveldb.OpenFile("path/to/db", nil) ... defer db.Close() ... 

Read or modify database contents:

 data, err := db.Get([]byte("key"), nil) ... err = db.Put([]byte("key"), []byte("value"), nil) ... err = db.Delete([]byte("key"), nil) ... 
+6
source

Source: https://habr.com/ru/post/915155/


All Articles