chore: delete code no binary or test reaches

This commit is contained in:
sam committed 2026-10-17 10:14:26 +11:00
1 parent 7986ccb3f7
commit 01acb97f96
34 files changed
+1 -1483

No files matched your search

-64
View File
@@ -327,70 +327,6 @@ func Tail(path string, q Query) (Result, error) {
return res, nil
}
// Page returns up to Limit matching entries from cursor, and the cursor to
// resume at. Truncated means older entries were not examined. A cursor past
// the end returns an empty page.
func Page(path string, q Query, cursor int64) (PageResult, error) {
res := PageResult{Entries: []Entry{}, File: path}
limit := q.Limit
if limit <= 0 {
limit = DefaultTailLines
}
if limit > MaxTailLines {
limit = MaxTailLines
}
// Stat for Found without reading the window twice. readLines cannot report
// the difference between a missing file and a cursor at EOF.
if strings.TrimSpace(path) != "" {
if _, err := os.Stat(path); err == nil {
res.Found = true
} else if !os.IsNotExist(err) {
return PageResult{}, fmt.Errorf("logging: stat %s: %w", path, err)
}
}
type lineAt struct {
entry Entry
endOff int64
}
matches := make([]lineAt, 0, limit)
truncated, endOff, ok, err := readLines(path, q, cursor, func(e Entry, _, end int64) bool {
if len(matches) < limit {
matches = append(matches, lineAt{entry: e, endOff: end})
return true
}
// Once we have limit matches, any further match means more is
// available; we keep walking only to maintain endOff accuracy.
res.MoreAvailable = true
return true
})
if err != nil {
return PageResult{}, err
}
if !ok {
// Preserved endOff carries the cursor the caller asked for
// (when ok=false because cursor > EOF, so the next call can
// detect overshoot). The scan-cap signal is also preserved.
res.Truncated = truncated
res.Cursor = endOff
return res, nil
}
res.Truncated = truncated
res.Entries = make([]Entry, len(matches))
for i, m := range matches {
res.Entries[i] = m.entry
}
// Resume after the last returned entry when the page filled, else at the end
// of the walk.
if res.MoreAvailable {
res.Cursor = matches[len(matches)-1].endOff
} else {
res.Cursor = endOff
}
return res, nil
}
// PageBefore returns up to Limit matching entries whose end offset is at or
// before before (the whole scan window when before is zero), oldest first. It
// is the backward counterpart of Page: Cursor is the before value for the next