diff --git a/flake.nix b/flake.nix index dccf7a4..f9013df 100644 --- a/flake.nix +++ b/flake.nix @@ -82,11 +82,8 @@ bad=$( # Snapshot outputs are generated with modified # indentation for alignment with annotations. - # pr261's input intentionally keeps an "unused" import - # to reproduce a panic on a bare PkgName ident. find . -name '*.go' \ -not -path '*/testdata/snapshots/output/*' \ - -not -path '*/testdata/snapshots/input/pr261/*' \ -exec ${pkgs.gotools}/bin/goimports -l {} + ) if [ -n "$bad" ]; then diff --git a/internal/testdata/snapshots/input/pr261/bare_pkg.go b/internal/testdata/snapshots/input/pr261/bare_pkg.go index ca1895c..4246c5c 100644 --- a/internal/testdata/snapshots/input/pr261/bare_pkg.go +++ b/internal/testdata/snapshots/input/pr261/bare_pkg.go @@ -2,4 +2,8 @@ package pr261 import "sort" +// Legitimate use so goimports doesn't strip the import. +var _ = sort.Slice + +// Bare PkgName reference that triggered the panic. var _ = sort diff --git a/internal/testdata/snapshots/output/pr261/bare_pkg.go b/internal/testdata/snapshots/output/pr261/bare_pkg.go index e5147a9..a80668a 100755 --- a/internal/testdata/snapshots/output/pr261/bare_pkg.go +++ b/internal/testdata/snapshots/output/pr261/bare_pkg.go @@ -8,5 +8,11 @@ import "sort" // ^^^^ reference github.com/golang/go/src go1.22 sort/ + // Legitimate use so goimports doesn't strip the import. + var _ = sort.Slice +// ^^^^ reference github.com/golang/go/src go1.22 sort/ +// ^^^^^ reference github.com/golang/go/src go1.22 sort/Slice(). + + // Bare PkgName reference that triggered the panic. var _ = sort