whatcanGOwrong
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
exec gofumpt -w foo.go
|
||||
cmp foo.go foo.go.golden
|
||||
|
||||
exec 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user