From 841a9047e20253201b9590e0b53efe7dfac7f321 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sun, 14 Jun 2026 21:11:49 +0200 Subject: [PATCH] style(example-dlna-server): satisfy golangci-lint (nilerr, revive) Two lint fixes on the DLNA test server, no behaviour change: - nilerr: the "skip unreadable file, keep walking" branch in the --media-dir WalkDir callback returns nil after a non-nil read error by design; annotate it with //nolint:nilerr, matching the existing skip-entry branch above it. - revive (redefines-builtin-id): rename between()'s `close` parameter (and `open` for symmetry) to closeTag/openTag so it no longer shadows the builtin `close`. Co-Authored-By: Claude Opus 4.8 (1M context) --- cmd/example-dlna-server/main.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/example-dlna-server/main.go b/cmd/example-dlna-server/main.go index e62fc17..22a3e4b 100644 --- a/cmd/example-dlna-server/main.go +++ b/cmd/example-dlna-server/main.go @@ -91,6 +91,7 @@ func main() { } opts = append(opts, dlnatest.WithTree(tree)) + logger.Info("serving real media from directory", "dir", *mediaDir, "tracks", n) } @@ -482,7 +483,7 @@ func loadTreeFromDir(dir, fallbackName string) (*dlnatest.Tree, int, error) { payload, rerr := os.ReadFile(path) if rerr != nil { - return nil // skip unreadable file + return nil //nolint:nilerr // skip unreadable file, keep walking } trackDir := filepath.Dir(path) @@ -675,17 +676,17 @@ func withAccessLog(logger *slog.Logger, next http.Handler) http.Handler { }) } -// between returns the text between the first occurrence of open and the next -// close, or "" if not found. Used for lightweight SOAP field extraction in logs. -func between(s, open, close string) string { - i := strings.Index(s, open) +// between returns the text between the first occurrence of openTag and the next +// closeTag, or "" if not found. Used for lightweight SOAP field extraction in logs. +func between(s, openTag, closeTag string) string { + i := strings.Index(s, openTag) if i < 0 { return "" } - i += len(open) + i += len(openTag) - j := strings.Index(s[i:], close) + j := strings.Index(s[i:], closeTag) if j < 0 { return "" }