Documentation ¶
Overview ¶
package warc provides primitives for reading and writing WARC files.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
Header provides information about the WARC record. It stores WARC record field names and their values. Since WARC field names are case-insensitive, the Header methods are case-insensitive as well.
type Mode ¶
type Mode int
Mode defines the way Reader will generate Records.
const ( // SequentialMode means Records have to be consumed one by one and a call to // ReadRecord() invalidates the previous record. The benefit is that // Records have almost no overhead since they wrap around // the underlying Reader. SequentialMode Mode = iota // AsynchronousMode means calls to ReadRecord don't effect previously // returned Records. This mode copies the Record's content into // separate memory, thus bears memory overhead. AsynchronousMode // DefaultMode defines the reading mode used in NewReader(). DefaultMode = AsynchronousMode )
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads WARC records from WARC files.
Example ¶
package main import ( "fmt" "os" "github.com/gavincarr/warc" ) func main() { reader, err := warc.NewReader(os.Stdin) if err != nil { panic(err) } defer reader.Close() for { record, err := reader.ReadRecord() if err != nil { break } fmt.Println("Record:") for key, value := range record.Header { fmt.Printf("%v = %v\n", key, value) } } }
Output:
func NewReaderMode ¶
NewReaderMode is like NewReader, but specifies the mode instead of assuming DefaultMode.
func (*Reader) ReadRecord ¶
ReadRecord reads the next record from the opened WARC file.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer writes WARC records to WARC files.
Example ¶
package main import ( "os" "strings" "github.com/gavincarr/warc" ) func main() { writer := warc.NewWriter(os.Stdout) record := warc.NewRecord() record.Header.Set("warc-type", "resource") record.Header.Set("content-type", "plain/text") record.Content = strings.NewReader("Hello, World!") if _, err := writer.WriteRecord(record); err != nil { panic(err) } }
Output:
Click to show internal directories.
Click to hide internal directories.