| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package main
- import (
- "fmt"
- //"os"
- "bytes"
- "github.com/repustate/go-cdb"
- )
- type rec struct {
- key string
- values []string
- }
- func main() {
- name := "test.cdb"
-
- r, err := cdb.NewReader(name)
- if err != nil {
- fmt.Printf("Failed opening database %q : %s\n", name, err)
- }
- defer r.Close()
-
- ok := r.Exists([]byte("two"), 0)
- if !ok {
- fmt.Printf("Expected to find key 'one' in tag 0 but did not.\n")
- }
- ok = r.Exists([]byte("two"), 1)
- if ok {
- fmt.Printf("Expected to not find key 'one' in tag 1 but did.\n")
- }
- v, ok := r.First([]byte("two"), 0)
- if !ok {
- fmt.Printf("Expected to find key 'one' in tag 0 but did not.\n")
- }
- if bytes.Compare(v, []byte("1")) != 0 {
- fmt.Printf("Expected value []byte{1} but got %#v.\n", v)
- }
-
- fmt.Printf("%s", string(v))
- }
|