From 2fa7605727e90ca323b7b24168632e485d74c583 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sun, 3 Mar 2024 04:59:34 +0700 Subject: all: comply with linter recommendations #2 HTTP request now implicitly create request with context. Any false positive related to not closing HTTP response body has been annotated with "nolint:bodyclose". In the example code, use consistent "// Output:" comment format, by prefixing with single space. Any comment on code now also prefixing with single space. An error returned without variables now use [errors.New] instead of [fmt.Errorf]. Any error returned using [fmt.Errorf] now wrapped using "%w" instead of "%s". Also, replace error checking using [errors.Is] or [errors.As], instead of using equal/not-equal operator. Any statement like "x = x OP y" now replaced with "x OP= y". Also, swap statement is simplified using "x, y = y, x". Any switch statement with single case now replaced with if-condition. Any call to defer on function or program that call [os.Exit], now replaced by calling the deferred function directly. Any if-else condition now replaced with switch statement, if possible. --- lib/net/html/example_node_iterator_test.go | 52 ++++++++++++++++-------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'lib/net/html/example_node_iterator_test.go') diff --git a/lib/net/html/example_node_iterator_test.go b/lib/net/html/example_node_iterator_test.go index 18eb9832..94ece050 100644 --- a/lib/net/html/example_node_iterator_test.go +++ b/lib/net/html/example_node_iterator_test.go @@ -34,22 +34,23 @@ func ExampleParse() { fmt.Printf("\t%s\n", node.Data) } } - //Output: - //html - //head - //body - //ul - //li - //b - // item - //b - //span - // one - //span - //li - //ul - //body - //html + + // Output: + // html + // head + // body + // ul + // li + // b + // item + // b + // span + // one + // span + // li + // ul + // body + // html } func ExampleNodeIterator_SetNext() { @@ -82,13 +83,14 @@ func ExampleNodeIterator_SetNext() { fmt.Printf("\t%s\n", node.Data) } } - //Output: - //html - //head - //body - //h2 - // Jump here - //h2 - //body - //html + + // Output: + // html + // head + // body + // h2 + // Jump here + // h2 + // body + // html } -- cgit v1.3