Documentation
¶
Overview ¶
Package cdb reads and writes cdb ("constant database") files.
See the original cdb specification and C implementation by D. J. Bernstein at http://cr.yp.to/cdb.html.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BadFormatError = errors.New("bad format")
Functions ¶
func Dump ¶
Dump reads the cdb-formatted data in r and dumps it as a series of formatted records (+klen,dlen:key->data\n) and a final newline to w. The output of Dump is suitable as input to Make. See http://cr.yp.to/cdb/cdbmake.html for details on the record format.
Types ¶
type Cdb ¶
type Cdb struct {
// contains filtered or unexported fields
}
func Open ¶
Open opens the named file read-only and returns a new Cdb object. The file should exist and be a cdb-format database file.
func (*Cdb) Data ¶
Data returns the first data value for the given key. If no such record exists, it returns EOF.
func (*Cdb) Find ¶
func (c *Cdb) Find(key []byte) (rdata *io.SectionReader, err error)
Find returns the first data value for the given key as a SectionReader. Find is the same as FindStart followed by FindNext.
func (*Cdb) FindNext ¶
func (c *Cdb) FindNext(key []byte) (rdata *io.SectionReader, err error)
FindNext returns the next data value for the given key as a SectionReader. If there are no more records for the given key, it returns EOF. FindNext acts as an iterator: The iteration should be initialized by calling FindStart and all subsequent calls to FindNext should use the same key value.