这是的实现。
安装
go get github.com/syndtr/goleveldb/leveldb
要求
至少需要go1.5或更高版本。
用法
创建或打开数据库:
// The returned DB instance is safe for concurrent use. Which mean that all
// DB's methods may be called concurrently from multiple goroutine.
db , err := leveldb . OpenFile ( "path/to/db" , nil )
...
defer db . Close ()
...
读取或修改数据库内容:
// Remember that the contents of the returned slice should not be modified.
data , err := db . Get ([] byte ( "key" ), nil )
...
err = db . Put ([] byte ( "key" ), [] byte (
1