From 5788345ed09761a3d4357ad352e99674fcb59769 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Mon, 27 May 2024 16:15:47 +0100 Subject: [PATCH] analysis/lint: don't print so many newlines for description The Before and After had extraneous newlines; before: % staticcheck -explain S1000 Use plain channel send or receive instead of single-case select Select statements with a single case can be replaced with a simple send or receive. Before: select { case x := <-ch: fmt.Println(x) } After: x := <-ch fmt.Println(x) Available since 2017.1 Online documentation https://staticcheck.dev/docs/checks#S1000 And after: % staticcheck -explain S1000 Use plain channel send or receive instead of single-case select Select statements with a single case can be replaced with a simple send or receive. Before: select { case x := <-ch: fmt.Println(x) } After: x := <-ch fmt.Println(x) Available since 2017.1 Online documentation https://staticcheck.dev/docs/checks#S1000 --- analysis/lint/lint.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/analysis/lint/lint.go b/analysis/lint/lint.go index eb97dc3f1..96ff402f3 100644 --- a/analysis/lint/lint.go +++ b/analysis/lint/lint.go @@ -167,13 +167,13 @@ func (doc *Documentation) format(markdown bool, metadata bool) string { if doc.Before != "" { fmt.Fprintln(b, "Before:") fmt.Fprintln(b, "") - for _, line := range strings.Split(doc.Before, "\n") { + for _, line := range strings.Split(strings.TrimSpace(doc.Before), "\n") { fmt.Fprint(b, " ", line, "\n") } fmt.Fprintln(b, "") fmt.Fprintln(b, "After:") fmt.Fprintln(b, "") - for _, line := range strings.Split(doc.After, "\n") { + for _, line := range strings.Split(strings.TrimSpace(doc.After), "\n") { fmt.Fprint(b, " ", line, "\n") } fmt.Fprintln(b, "")