tests/sdb_viewer/main.go

25 lines
519 B
Go

package main
import (
"fmt"
"github.com/lanzafame/berkeleydb"
)
func main() {
db, err := berkeleydb.NewDB()
if err != nil {
fmt.Printf("Unexpected failure of CreateDB %s\n", err)
}
if err := db.Open("test/9.4.sdb", berkeleydb.DbUnknown, berkeleydb.DbRdOnly); err != nil {
fmt.Printf("Could not open test_db.db. Error code %s", err)
return
}
defer db.Close()
value, err := db.Get("key")
if err != nil {
fmt.Printf("Unexpected error in Get: %s\n", err)
return
}
fmt.Printf("value: %s\n", value)
}