func Example() { writer, err := cdb.Create("/tmp/example.cdb") if err != nil { log.Fatal(err) } // Write some key/value pairs to the database. writer.Put([]byte("Alice"), []byte("Practice")) writer.Put([]byte("Bob"), []byte("Hope")) writer.Put([]byte("Charlie"), []byte("Horse")) // Freeze the database, and open it for reads. db, err := writer.Freeze() if err != nil { log.Fatal(err) } // Fetch a value. v, err := db.Get([]byte("Alice")) if err != nil { log.Fatal(err) } fmt.Println(string(v)) // Output: Practice }
func ExampleWriter() { writer, err := cdb.Create("/tmp/example.cdb") if err != nil { log.Fatal(err) } // Write some key/value pairs to the database. writer.Put([]byte("Alice"), []byte("Practice")) writer.Put([]byte("Bob"), []byte("Hope")) writer.Put([]byte("Charlie"), []byte("Horse")) // It's important to call Close or Freeze when you're finished writing // records. writer.Close() }