1+ //go:build ignore
2+
3+ // TODO(ldez) the linter doesn't support cgo.
14//golangcitest:args -Ewhitespace
25//golangcitest:config_path testdata/whitespace.yml
36package testdata
47
5- /*
6- #include <stdio.h>
7- #include <stdlib.h>
8-
9- void myprint(char* s) {
10- printf("%d\n", s);
11- }
12- */
13- import "C"
14-
15- import (
16- "fmt"
17- "strings"
18- "unsafe"
19- )
20-
21- func _ () {
22- cs := C .CString ("Hello from stdio\n " )
23- C .myprint (cs )
24- C .free (unsafe .Pointer (cs ))
25- }
8+ import "fmt"
269
27- func oneLeadingNewline () {
10+ func oneLeadingNewline () { // want "unnecessary leading newline"
2811
2912 fmt .Println ("Hello world" )
3013}
3114
32- func oneNewlineAtBothEnds () {
15+ func oneNewlineAtBothEnds () { // want "unnecessary leading newline"
3316
3417 fmt .Println ("Hello world" )
3518
36- }
19+ } // want "unnecessary trailing newline"
3720
3821func noNewlineFunc () {
3922}
@@ -61,36 +44,36 @@ func oneLeadingNewlineWithCommentFunc() {
6144 // some comment
6245}
6346
64- func twoLeadingNewlines () {
47+ func twoLeadingNewlines () { // want "unnecessary leading newline"
6548
6649
6750 fmt .Println ("Hello world" )
6851}
6952
7053func multiFuncFunc (a int ,
71- b int ) {
54+ b int ) { // want "multi-line statement should be followed by a newline"
7255 fmt .Println ("Hello world" )
7356}
7457
7558func multiIfFunc () {
7659 if 1 == 1 &&
77- 2 == 2 {
60+ 2 == 2 { // want "multi-line statement should be followed by a newline"
7861 fmt .Println ("Hello multi-line world" )
7962 }
8063
8164 if true {
8265 if true {
8366 if true {
8467 if 1 == 1 &&
85- 2 == 2 {
68+ 2 == 2 { // want "multi-line statement should be followed by a newline"
8669 fmt .Println ("Hello nested multi-line world" )
8770 }
8871 }
8972 }
9073 }
9174}
9275
93- func notGoFmted () {
76+ func notGoFmted () { // want "unnecessary leading newline"
9477
9578
9679
@@ -99,4 +82,4 @@ func notGoFmted() {
9982
10083
10184
102- }
85+ } // want "unnecessary trailing newline"
0 commit comments