fix: bug fixes, test coverage, and CI workflow
Some checks failed
CI / vet (push) Failing after 15s
CI / build (push) Failing after 30s
CI / test (push) Failing after 36s

- Fix Nodes.First() panic on empty slice (return nil)
- Fix ticker leak in archive.go (create once, defer Stop)
- Fix cookie path matching for empty and root paths
- Fix lost query params in google.go (u.Query().Set was discarded)
- Fix type assertion panic in useragents.go
- Fix dropped date parse error in powerball.go
- Remove unreachable dead code in megamillions.go and powerball.go
- Simplify document.go WaitForNetworkIdle, remove unused root field
- Remove debug fmt.Println calls across codebase
- Replace panic(err) with stderr+exit in all cmd/ programs
- Fix duckduckgo cmd: remove useless defer, return error on bad safesearch
- Fix archive cmd: ToConfig returns error instead of panicking
- Add 39+ unit tests across 6 new test files
- Add Gitea Actions CI workflow (build, test, vet in parallel)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-09 11:14:05 -05:00
parent e807dbb2ff
commit e7b7e78796
25 changed files with 868 additions and 117 deletions

View File

@@ -51,10 +51,8 @@ func main() {
},
}
err := cli.Run(context.Background(), os.Args)
if err != nil {
panic(err)
if err := cli.Run(context.Background(), os.Args); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}

View File

@@ -41,9 +41,20 @@ func deferClose(cl io.Closer) {
func getDrawing(_ context.Context, doc extractor.Document) (*Drawing, error) {
var drawing Drawing
dateStr, err := doc.SelectFirst("#numbers .title-date").Text()
dateNode := doc.SelectFirst("#numbers .title-date")
if dateNode == nil {
return nil, fmt.Errorf("failed to find date element")
}
dateStr, err := dateNode.Text()
if err != nil {
return nil, fmt.Errorf("failed to get date text: %w", err)
}
drawing.Date, err = time.Parse("Mon, Jan 2, 2006", dateStr)
if err != nil {
return nil, fmt.Errorf("failed to parse date %q: %w", dateStr, err)
}
nums := doc.Select("div.game-ball-group div.white-balls")
@@ -165,22 +176,12 @@ func getNextDrawing(_ context.Context, doc extractor.Document) (*NextDrawing, er
numeric := numericOnly(txt)
set := false
if strings.Contains(txt, "Billion") {
amt := numeric * 1000000000
nextDrawing.JackpotDollars = int(amt)
set = true
nextDrawing.JackpotDollars = int(numeric * 1000000000)
} else if strings.Contains(txt, "Million") {
amt := numeric * 1000000
nextDrawing.JackpotDollars = int(amt)
set = true
nextDrawing.JackpotDollars = int(numeric * 1000000)
} else {
nextDrawing.JackpotDollars = int(numeric)
set = true
}
if !set {
return nil, fmt.Errorf("failed to convert jackpot to currency: %w", err)
}
return &nextDrawing, nil