+++ /dev/null
-[!gofumpt] skip 'don''t add or remove imports'
-
-gofumpt -w foo.go
-cmp foo.go foo.go.golden
-
-gofumpt -d foo.go.golden
-! stdout .
-
--- foo.go --
-package p
-
-import (
- "io"
- "io/ioutil" // if the user keeps them in the top group, obey that
- _ "io/ioutil"
-
- _ "image/png"
-
- "bufio" // the above is for a side effect; this one has a comment
-)
-
-import (
- "os"
-
- "foo.local/one"
-
- bytes_ "bytes"
-
- "io"
-)
-
-import (
- "foo.local/two"
-
- "fmt"
-)
-
-// If they are in order, but with extra newlines, join them.
-import (
- "more"
-
- "std"
-)
-
-// We need to split std vs non-std in this case too.
-import (
- "foo.local/three"
- math "math"
-)
-
-import (
- "x"
- // don't mess up this comment
- "y"
- // or many
- // of them
- "z"
-)
-
-// This used to crash gofumpt, as there's no space to insert an extra newline.
-import (
-"std"
-"non.std/pkg"
-)
-
-// All of the extra imports below are known to not belong in std.
-// For example/ and test/, see https://golang.org/issue/37641.
-import (
- "io"
-
- "example/foo"
- "internal/bar"
- "test/baz"
-)
--- foo.go.golden --
-package p
-
-import (
- "io"
- "io/ioutil" // if the user keeps them in the top group, obey that
- _ "io/ioutil"
-
- _ "image/png"
-
- "bufio" // the above is for a side effect; this one has a comment
-)
-
-import (
- "io"
- "os"
-
- "foo.local/one"
-
- bytes_ "bytes"
-)
-
-import (
- "fmt"
-
- "foo.local/two"
-)
-
-// If they are in order, but with extra newlines, join them.
-import (
- "more"
- "std"
-)
-
-// We need to split std vs non-std in this case too.
-import (
- math "math"
-
- "foo.local/three"
-)
-
-import (
- "x"
- // don't mess up this comment
- "y"
- // or many
- // of them
- "z"
-)
-
-// This used to crash gofumpt, as there's no space to insert an extra newline.
-import (
- "std"
-
- "non.std/pkg"
-)
-
-// All of the extra imports below are known to not belong in std.
-// For example/ and test/, see https://golang.org/issue/37641.
-import (
- "io"
-
- "example/foo"
- "internal/bar"
- "test/baz"
-)