xushiwei / leveldb-go Goto Github PK
View Code? Open in Web Editor NEWleveldb-go
License: BSD 3-Clause "New" or "Revised" License
leveldb-go
License: BSD 3-Clause "New" or "Revised" License
This is a LevelDB library for the Go programming language. To download and install from source: $ go get code.google.com/p/leveldb-go/leveldb Unless otherwise noted, the LevelDB-Go source files are distributed under the BSD-style license found in the LICENSE file. Contributions should follow the same procedure as for the Go project: http://golang.org/doc/contribute.html
Hi,
I tried to use leveldb-go, but I got the following error message
panic: leveldb/table: invalid table (could not stat file)
When attempting to run the snippet hereunder.
Is this a bug or did I do something wrong in this code ?
Thanks,
Serge.
package main
import (
"code.google.com/p/leveldb-go/leveldb/db"
"code.google.com/p/leveldb-go/leveldb/table"
"fmt"
//"runtime"
)
const (
DBFILE = "/home/serge2/workspace/scanner_go_test_7/tmp/leveldb_4.db"
)
var DBFS = db.DefaultFileSystem
func Check(e error) {
if e != nil {
panic(e)
}
}
func main() {
Connection, e := DBFS.Create(DBFILE)
Check(e)
// -- Writer :
w := table.NewWriter(Connection, nil)
e = w.Set([]byte("Hello"), []byte("World"), nil)
Check(e)
w.Close()
// -- Reader :
r := table.NewReader(Connection, nil)
b := []byte("")
iter := r.Find(b, nil)
for iter.Next() {
k := iter.Key()
v := iter.Value()
fmt.Printf("key = %s\n", k)
fmt.Printf("value = %s\n", v)
}
e = iter.Close()
Check(e)
e = r.Close()
Check(e)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.