Fix golangci-lint errcheck warnings; add make fixstyle

errcheck flagged six unchecked Close() calls. The production write
path in indexgen.ProcessDir now closes the index file explicitly
after Execute and surfaces the close error so a deferred flush
failure isn't lost; tests use _ = f.Close() since they don't care.

Also adds a 'make fixstyle' target that runs gofmt -w over the tree,
matching the convention used elsewhere.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-06 20:17:10 +02:00
parent 535a121435
commit abc9729e8e
4 changed files with 19 additions and 15 deletions
+5 -4
View File
@@ -245,12 +245,13 @@ func ProcessDir(topDir string, opts *Options) error {
if err != nil {
return fmt.Errorf("cannot create file %s: %w", indexPath, err)
}
defer file.Close()
err = GetHTMLTemplate().Execute(file, templateData)
if err != nil {
if err := GetHTMLTemplate().Execute(file, templateData); err != nil {
_ = file.Close()
return fmt.Errorf("failed to execute template: %w", err)
}
if err := file.Close(); err != nil {
return fmt.Errorf("failed to close file %s: %w", indexPath, err)
}
}
if opts.Recursive {