package main
import ( "fmt" "github.com/syndtr/goleveldb/leveldb" ) //for test func write_leveldb() { // db, err := leveldb.OpenFile("/home/brian/.tendermint/data", nil) db, err := leveldb.OpenFile("./data/blockstore.db", nil) if err != nil { panic(err) } db.Put([]byte("id"), []byte("10000"), nil) db.Close() } //for test func read_leveldb() { db, err1 := leveldb.OpenFile("./data/blockstore.db", nil) if err1 != nil { panic(err1) } ids, err2 := db.Get([]byte("id"), nil) if err2 != nil { panic(err2) } id := string(ids) fmt.Println("read leveldb:", id) db.Close() } func main() { write_leveldb() read_leveldb() }