Skip to content

Commit

Permalink
document the removal of empty lines surrounding field lists
Browse files Browse the repository at this point in the history
Our documentation of the rule was actually incorrect.
We always applied it to all field lists, not interfaces.
And we didn't take comments into account yet,
which is what the recent change improved upon.

While here, remove unintentional whitespace from the added tests.
  • Loading branch information
mvdan committed Feb 20, 2022
1 parent 9827b59 commit 6b39b9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ var _ = map[string]string{

</details>

Interfaces should not have leading or trailing empty lines
Field lists should not have leading or trailing empty lines

<details><summary><i>example</i></summary>

Expand All @@ -396,6 +396,12 @@ type Person interface {
Age() int
}
type ZeroFields struct {
// No fields are needed here.
}
```

Expand All @@ -405,6 +411,10 @@ type Person interface {
Age() int
}
type ZeroFields struct {
// No fields are needed here.
}
```

</details>
Expand Down
15 changes: 6 additions & 9 deletions testdata/scripts/block-empty.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ func f() {


// lone comment


}

type I interface {


// lone comment


}


Expand All @@ -43,19 +43,16 @@ func f() {
type SOut struct {

// lone comment

}

type IOut interface {


// lone comment


}



-- foo.go.golden --
package p

Expand Down

0 comments on commit 6b39b9e

Please sign in to comment.