Documentation ¶
Overview ¶
Package recordio implements a file format for a sequence of records. It could be used to store, for example, serialized data structures to disk.
Records are stored as an unsigned varint specifying the length of the data, and then the data itself as a binary blob.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
A Scanner is a convenient method for reading records sequentially.
Example ¶
package main import ( "fmt" "log" "os" "github.com/eclesh/recordio" ) func main() { f, err := os.Open("file.dat") if err != nil { log.Fatalln(err) } defer f.Close() scanner := recordio.NewScanner(f) for scanner.Scan() { fmt.Println(scanner.Bytes()) } if err := scanner.Err(); err != nil { log.Fatalln(err) } }
Output:
func NewScanner ¶
NewScanner creates a new Scanner from reader r.
func (*Scanner) Bytes ¶
Bytes returns the most recently scanned record. Subsequent calls may overwrite the returned data, so you must copy it if not using it immediately.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Example ¶
package main import ( "log" "os" "github.com/eclesh/recordio" ) func main() { f, err := os.Create("file.dat") if err != nil { log.Fatalln(err) } w := recordio.NewWriter(f) w.Write([]byte("this is a record")) w.Write([]byte("this is a second record")) f.Close() }
Output:
Click to show internal directories.
Click to hide internal directories.