forked from mvdan/gofumpt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
format: exclude body on CaseClause len check
fixes mvdan#217
- Loading branch information
Showing
4 changed files
with
199 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
gofumpt -w foo.go | ||
cmp foo.go foo.go.golden | ||
|
||
gofumpt -d foo.go.golden | ||
! stdout . | ||
|
||
-- foo.go -- | ||
package p | ||
|
||
func f(r rune) { | ||
switch r { | ||
case 'a', | ||
'b', | ||
'c': | ||
|
||
case 'd', 'e', 'f': | ||
|
||
case 'a', 'b', | ||
'c': | ||
|
||
case 'v', 'e', 'r', 'y', 'l', 'o', 'n', 'g', | ||
'l', 'i', 's', 't', '.', '.', '.': | ||
|
||
// before | ||
case 'a', | ||
'b': // inline | ||
// after | ||
|
||
case 'a', // middle | ||
'b': | ||
|
||
case 'a', 'b', 'c', 'd', 'e', 'f', | ||
'g': // very very long inline comment at the end | ||
|
||
case 'a', 'b', 'c', | ||
'd': // short comment | ||
} | ||
{ | ||
{ | ||
{ | ||
{ | ||
{ | ||
switch r { | ||
case 'i', 'n', 'd', 'e', | ||
'n', 't', 'e', 'd': | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func s(x int) { | ||
switch x { | ||
case | ||
shortConstant1, | ||
shortConstant2: | ||
// A comment. | ||
fmt.Println(x) | ||
case | ||
shortConstant3, | ||
shortConstant4: | ||
// Do nothing. | ||
default: | ||
// Another comment. | ||
fmt.Println(x * 2) | ||
} | ||
} | ||
|
||
func s(x int) { | ||
switch x { | ||
case | ||
longerConstantName1, | ||
longerConstantName2: | ||
// A comment. | ||
fmt.Println(x) | ||
case | ||
longerConstantName3, | ||
longerConstantName4: | ||
// Do nothing. | ||
default: | ||
// Another comment. | ||
fmt.Println(x * 2) | ||
} | ||
} | ||
-- foo.go.golden -- | ||
package p | ||
|
||
func f(r rune) { | ||
switch r { | ||
case 'a', 'b', 'c': | ||
|
||
case 'd', 'e', 'f': | ||
|
||
case 'a', 'b', 'c': | ||
|
||
case 'v', 'e', 'r', 'y', 'l', 'o', 'n', 'g', | ||
'l', 'i', 's', 't', '.', '.', '.': | ||
|
||
// before | ||
case 'a', 'b': // inline | ||
// after | ||
|
||
case 'a', // middle | ||
'b': | ||
|
||
case 'a', 'b', 'c', 'd', 'e', 'f', | ||
'g': // very very long inline comment at the end | ||
|
||
case 'a', 'b', 'c', 'd': // short comment | ||
} | ||
{ | ||
{ | ||
{ | ||
{ | ||
{ | ||
switch r { | ||
case 'i', 'n', 'd', 'e', | ||
'n', 't', 'e', 'd': | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func s(x int) { | ||
switch x { | ||
case shortConstant1, shortConstant2: | ||
// A comment. | ||
fmt.Println(x) | ||
case shortConstant3, shortConstant4: | ||
// Do nothing. | ||
default: | ||
// Another comment. | ||
fmt.Println(x * 2) | ||
} | ||
} | ||
|
||
func s(x int) { | ||
switch x { | ||
case | ||
longerConstantName1, | ||
longerConstantName2: | ||
// A comment. | ||
fmt.Println(x) | ||
case | ||
longerConstantName3, | ||
longerConstantName4: | ||
// Do nothing. | ||
default: | ||
// Another comment. | ||
fmt.Println(x * 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters