elf

package
v0.0.0-...-a602f81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// List of fields as for the Field descriptor.
	// This field gets populated by reader during the read.
	Fields []string
	// Version of the ELF format used, as for the Version descriptor.
	// This field gets populated by reader during the read.
	Version string
	// Software that created the ELF file, as for the Software descriptor.
	// This field gets populated by reader during the read.
	Software string
	// StartDate of the oldest entry, as for the StartDate descriptor.
	// This field gets populated by reader during the read.
	StartDate string
	// EndDate of the oldest entry, as for the EndDate descriptor.
	// This field gets populated by reader during the read.
	EndDate string
	// Date of the oldest entry, as for the Date descriptor.
	// This field gets populated by reader during the read.
	Date string
	// Remarks, as for the Remarks descriptor.
	// This field gets populated by reader during the read.
	Remark string
	// contains filtered or unexported fields
}

A Reader reads records from an Extended Log Format file.

As returned by NewReader, a Reader expects input conforming to the W3C ELF. The exported fields are populated by the Read and the ReadAll functions.

The Reader manages both \r\n and \n sequences.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader returns a new Reader that reads from r.

func (*Reader) Read

func (r *Reader) Read() (record map[string]string, err error)

Read reads one record (a slice of fields) from r. If the record has an unexpected number of fields, it returns an error

Read always returns either a non-nil record or a non-nil error, but not both. The only exception is if the line is a comment or empty, then both the record and the error will be nil.

If there is no data left to be read, Read returns nil, io.EOF.

func (*Reader) ReadAll

func (r *Reader) ReadAll() (records []map[string]string, err error)

ReadAll reads all the remaining records from r. Each record is a map of fields. A successful call returns err == nil, not err == io.EOF. Because ReadAll is defined to read until EOF, it does not treat end of file as an error to be reported.

type Writer

type Writer struct {
	Fields    []string
	Version   string
	Software  string
	StartDate string
	EndDate   string
	Date      string
	Remark    string
	Separator rune // Field delimiter (set to '\t' by NewWriter)
	UseCRLF   bool // True to use \r\n as the line terminator
	// contains filtered or unexported fields
}

Writer writes records to an ELF encoded file.

func NewWriter

func NewWriter(w io.Writer, fields []string) *Writer

NewWriter returns a new Writer that writes to w.

func (*Writer) Error

func (w *Writer) Error() error

Error reports any error that has occurred during a previous Write or Flush.

func (*Writer) Flush

func (w *Writer) Flush()

Flush writes any buffered data to the underlying io.Writer. To check if an error occurred during the Flush, call Error.

func (*Writer) Write

func (w *Writer) Write(record map[string]string) error

func (*Writer) WriteAll

func (w *Writer) WriteAll(records []map[string]string) error

WriteAll writes multiple elf records to w using Write and then calls Flush.

func (*Writer) WriteHeaders

func (w *Writer) WriteHeaders() error

WriteHeaders write the ELF file header lines

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL