Documentation
¶
Index ¶
- func Append(path string, res speedtest.Result) error
- func CSV(w io.Writer, records []speedtest.Result) error
- func DefaultPath() (string, error)
- func Filter(records []speedtest.Result, since, until time.Time) []speedtest.Result
- func JSON(w io.Writer, records []speedtest.Result) error
- func LastN(records []speedtest.Result, n int) []speedtest.Result
- func Load(path string) ([]speedtest.Result, int, error)
- func ParseBound(s string, end bool, now time.Time) (time.Time, error)
- func RenderSummary(w io.Writer, s Summary, st *output.Styler)
- func Table(w io.Writer, records []speedtest.Result, total int, st *output.Styler)
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
Append writes the result as one JSON line to the file at path, creating parent directories and the file if needed.
func CSV ¶ added in v0.1.7
CSV writes records as CSV with a header row. Empty input writes just the header.
func DefaultPath ¶
DefaultPath returns the default history file location under the user's home.
func Filter ¶ added in v0.1.8
Filter returns the records whose Timestamp falls within [since, until], inclusive. A zero since or until means unbounded on that side. The result is a new slice preserving the original order.
func JSON ¶ added in v0.1.7
JSON writes records as a 2-space-indented JSON array. Empty input writes [].
func LastN ¶ added in v0.1.7
LastN returns the most recent n records (records are oldest-first, so the tail). n <= 0 or n >= len returns all records.
func Load ¶ added in v0.1.7
Load reads the history file at path, returning the records in file order (oldest first) and the number of malformed lines skipped. A missing file returns (nil, 0, nil); a genuine read error is returned. Parsing is best-effort: a bad line is counted and skipped, never fatal.
func ParseBound ¶ added in v0.1.8
ParseBound parses a date-range bound. An empty string returns the zero time (unbounded). Relative durations (7d/24h/30m) return now minus that duration. "YYYY-MM-DD HH:MM" returns that exact local time. "YYYY-MM-DD" returns the start of that day for a lower bound (end=false) or the end of that day (end=true), so a bare --until date includes the whole day. Local time is used.
func RenderSummary ¶ added in v0.1.7
RenderSummary renders the avg/min/max stats block from a computed Summary.