From de3450b2c254d578a56db3afdcea7252965ffd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 22 Feb 2022 17:33:29 +0000 Subject: [PATCH 01/10] CHANGELOG: add missing tag link Forgetting this is a classic. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 664b430..3a23bd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,7 @@ those building programs with gofumpt. Finally, this release adds the `-version` flag, to print the tool's own version. The flag will work for "master" builds too. +[0.3.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.3.0 [0.2.1]: https://github.com/mvdan/gofumpt/releases/tag/v0.2.1 [0.2.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.2.0 [0.1.1]: https://github.com/mvdan/gofumpt/releases/tag/v0.1.1 From 6952740a867076a42f5a1b40b2292eab56fd7484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 23 Feb 2022 15:57:14 +0000 Subject: [PATCH 02/10] format: fix copy-paste mistake in Options.ModulePath I used LangVersion as a starting point, and I must have forgot to delete some of the old lines when modifying in-place. Thanks to Rob Findley for spotting this. --- format/format.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/format/format.go b/format/format.go index 6f797ca..8651085 100644 --- a/format/format.go +++ b/format/format.go @@ -46,8 +46,6 @@ type Options struct { // ModulePath corresponds to the Go module path which contains the source // code being formatted. When inside a Go module, ModulePath should be: - // rules which require new language features. When inside a Go module, - // LangVersion should generally be specified as the result of: // // go mod edit -json | jq -r '.Module.Path' // From 2becf2f780ca0a0a7d9ac92b12d733c30072afca Mon Sep 17 00:00:00 2001 From: gustav-b Date: Fri, 4 Mar 2022 10:25:58 +0100 Subject: [PATCH 03/10] =?UTF-8?q?README:=20tweak=20setup=20instructions=20?= =?UTF-8?q?for=20Emacs=20lsp-mode=20=E2=89=A5=208.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Emacs lsp-mode 8.0.0 release, https://github.com/emacs-lsp/lsp-mode/releases/tag/8.0.0, exposed the gofumpt setting as a custom variable. Updates the installation instructions with the new setting, while keeping the old method for versions below 8.0.0. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 534b1b6..56de828 100644 --- a/README.md +++ b/README.md @@ -535,6 +535,11 @@ require('lspconfig').gopls.setup({ For [lsp-mode](https://emacs-lsp.github.io/lsp-mode/) users: +```elisp +(setq lsp-go-use-gofumpt t) +``` + +For users of `lsp-mode` before `8.0.0`: ```elisp (lsp-register-custom-settings '(("gopls.gofumpt" t))) From 06043a62ed11a9646c728f772ed04bd7409912cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 4 Mar 2022 09:30:06 +0000 Subject: [PATCH 04/10] README: stop mentioning govim and vim-go versions Both Vim plugins added support for gofumpt via gopls well over a year ago. Stop ensuring the user is up to date, because they most likely are. --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 56de828..0de9a9d 100644 --- a/README.md +++ b/README.md @@ -499,9 +499,7 @@ To avoid unnecessary runs, you should disable all checkboxes in the *Advanced* s #### Vim-go -Ensure you are at least running version -[v1.24](https://github.com/fatih/vim-go/blob/master/CHANGELOG.md#v124---september-15-2020), -and set up `gopls` for formatting code with `gofumpt`: +To configure `gopls` to use `gofumpt`: ```vim let g:go_fmt_command="gopls" @@ -510,8 +508,7 @@ let g:go_gopls_gofumpt=1 #### Govim -With a [new enough version of govim](https://github.com/govim/govim/pull/1005), -simply configure `gopls` to use `gofumpt`: +To configure `gopls` to use `gofumpt`: ```vim call govim#config#Set("Gofumpt", 1) @@ -533,13 +530,14 @@ require('lspconfig').gopls.setup({ #### Emacs -For [lsp-mode](https://emacs-lsp.github.io/lsp-mode/) users: +For [lsp-mode](https://emacs-lsp.github.io/lsp-mode/) users on version 8.0.0 or higher: ```elisp (setq lsp-go-use-gofumpt t) ``` For users of `lsp-mode` before `8.0.0`: + ```elisp (lsp-register-custom-settings '(("gopls.gofumpt" t))) From 9b05d69ed3e90cf90b00256ebd686dd68642be19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 16 Mar 2022 15:57:00 +0000 Subject: [PATCH 05/10] drop Go 1.16, test on 1.18, add checks --- .github/workflows/test.yml | 19 ++++++++++++------- go.mod | 10 +++++++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05bce8f..a46f810 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,15 +4,20 @@ jobs: test: strategy: matrix: - go-version: [1.16.x, 1.17.x] + go-version: [1.17.x, 1.18.x] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - - name: Install Go - uses: actions/setup-go@v2 + - uses: actions/setup-go@v3 with: go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v2 - - name: Test - run: go test ./... + - uses: actions/checkout@v3 + - run: go test ./... + - run: go test -race ./... + + # Static checks from this point forward. Only run on one Go version and on + # Linux, since it's the fastest platform, and the tools behave the same. + - if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.18.x' + run: diff <(echo -n) <(gofmt -s -d .) + - if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.18.x' + run: go vet ./... diff --git a/go.mod b/go.mod index ee610fb..150cbc7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module mvdan.cc/gofumpt -go 1.16 +go 1.17 require ( github.com/frankban/quicktest v1.14.2 @@ -11,3 +11,11 @@ require ( golang.org/x/sys v0.0.0-20220209214540-3681064d5158 golang.org/x/tools v0.1.9 ) + +require ( + github.com/kr/pretty v0.3.0 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + gopkg.in/errgo.v2 v2.1.0 // indirect +) From edc2d69c21baad54315066236d980c90dbe64f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 16 Mar 2022 21:54:35 +0000 Subject: [PATCH 06/10] README: update version info now that Go 1.18 is out cmd/gofmt saw no changes since 1.18rc1. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0de9a9d..c194fc8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Enforce a stricter format than `gofmt`, while being backwards compatible. That is, `gofumpt` is happy with a subset of the formats that `gofmt` is happy with. -The tool is a modified fork of `gofmt` as of Go 1.18rc1. +The tool is a modified fork of `gofmt` as of Go 1.18. It can be used as a drop-in replacement to format your Go code, and running `gofmt` after `gofumpt` should produce no changes. For example: From 9eee203c42f9cae05fc38b02fea6d3d11135c782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 18 Mar 2022 11:13:28 +0000 Subject: [PATCH 07/10] remove unintentional debug prints These were introduced when syncing gofumpt with gofmt from Go 1.18rc1. I didn't notice partially because our tests weren't strict enough; fix that as well. While here, gofumpt our own source code. --- format/format.go | 1 - gofmt.go | 2 -- testdata/scripts/ignore-implicit-vendor.txt | 10 +++++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/format/format.go b/format/format.go index 8651085..727acce 100644 --- a/format/format.go +++ b/format/format.go @@ -912,7 +912,6 @@ func (f *fumpter) joinStdImports(d *ast.GenDecl) { periodIndex := strings.IndexByte(path, '.') slashIndex := strings.IndexByte(path, '/') switch { - // Imports with a period in the first path element are third party. // Note that this includes "foo.com" and excludes "foo/bar.com/baz". case periodIndex > 0 && (slashIndex == -1 || periodIndex < slashIndex), diff --git a/gofmt.go b/gofmt.go index ca60bc3..4d29520 100644 --- a/gofmt.go +++ b/gofmt.go @@ -502,9 +502,7 @@ func gofmtMain(s *sequencer) { case !info.IsDir(): // Non-directory arguments are always formatted. arg := arg - println(arg) s.Add(fileWeight(arg, info), func(r *reporter) error { - println(arg) return processFile(arg, info, nil, r, true) }) default: diff --git a/testdata/scripts/ignore-implicit-vendor.txt b/testdata/scripts/ignore-implicit-vendor.txt index ac53ef2..23f622d 100644 --- a/testdata/scripts/ignore-implicit-vendor.txt +++ b/testdata/scripts/ignore-implicit-vendor.txt @@ -5,21 +5,25 @@ cp orig.go.golden vendor/foo/foo.go # format explicit vendor dir gofumpt -l vendor -stdout 'vendor[/\\]foo[/\\]foo.go' +stdout -count=1 'vendor[/\\]foo[/\\]foo.go' +! stderr . # format explicit vendor file gofumpt -l vendor/foo/foo.go -stdout 'vendor[/\\]foo[/\\]foo.go' +stdout -count=1 'vendor[/\\]foo[/\\]foo.go' +! stderr . # ignore implicit vendor call gofumpt -l . ! stdout . +! stderr . # format explicit vendor pkg while ignoring rest mkdir vendor/ignore cp orig.go.golden vendor/ignore/ignore.go gofumpt -l vendor/foo . -stdout 'vendor[/\\]foo[/\\]foo.go' +stdout -count=1 'vendor[/\\]foo[/\\]foo.go' +! stderr . -- orig.go.golden -- package p From 1dfe9cab509c58b38fdbc3d905c6c19a41b240f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 18 Mar 2022 16:53:42 +0000 Subject: [PATCH 08/10] overhaul how we load module info to format Go files We would call "go mod edit -json" for each Go file we formatted, as each file may be in a different directory, and thus inside a different module. However, the first mistake is that we always ran the command in the directory where gofumpt is run, not the directory containing each Go file. Our tests weren't strict enough to catch this; now octal-literal.txt is, via its run of gofmt before it calls cd. The second mistake, and a pretty embarrassing one, is that since v0.3.0 made gofumpt concurrent, it has been racy in how it writes to globals like langVersion from multiple goroutines. octal-literals.txt now tests for this by adding a nested Go module. Finally, we could also run into open file limits, because spawning a child process and grabbing its output opens files of its own such as named pipes. The added test shows this with a limit of 256 and 10k tiny Go files: --- FAIL: TestWithLowOpenFileLimit (0.30s) ulimit_unix_test.go:82: writing 10000 tiny Go files ulimit_unix_test.go:104: running with 1 paths ulimit_unix_test.go:104: running with 10000 paths ulimit_unix_test.go:112: error: got non-nil error comment: stderr: open /tmp/TestWithLowOpenFileLimit2753748366/001/p003/014.go: too many open files open /tmp/TestWithLowOpenFileLimit2753748366/001/p003/017.go: too many open files open /tmp/TestWithLowOpenFileLimit2753748366/001/p004/000.go: too many open files open /tmp/TestWithLowOpenFileLimit2753748366/001/p004/019.go: too many open files Instead, only call "go mod edit -json" once per directory, and do it in the main thread to reduce its parallelism. Also make it grab fdSem as well, for good measure. This may not be a complete fix, as we're not sure how many files are open by an exec.Command.Output call. However, we are no longer able to reproduce a failure, so leave that as a TODO. Fixes #208. --- gofmt.go | 70 ++++++++++++++++----- testdata/scripts/octal-literals.txt | 43 ++++++++----- testdata/scripts/workspaces.txt | 30 ++++----- ulimit_unix_test.go | 94 +++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+), 44 deletions(-) create mode 100644 ulimit_unix_test.go diff --git a/gofmt.go b/gofmt.go index 4d29520..6390d83 100644 --- a/gofmt.go +++ b/gofmt.go @@ -23,6 +23,7 @@ import ( "runtime" "runtime/pprof" "strings" + "sync" "golang.org/x/sync/semaphore" exec "golang.org/x/sys/execabs" @@ -287,21 +288,18 @@ func processFile(filename string, info fs.FileInfo, in io.Reader, r *reporter, e // Apply gofumpt's changes before we print the code in gofumpt's format. // If either -lang or -modpath aren't set, fetch them from go.mod. - if *langVersion == "" || *modulePath == "" { - out, err := exec.Command("go", "mod", "edit", "-json").Output() - if err == nil && len(out) > 0 { - var mod struct { - Go string - Module struct { - Path string - } - } - _ = json.Unmarshal(out, &mod) - if *langVersion == "" { - *langVersion = mod.Go + lang := *langVersion + modpath := *modulePath + if lang == "" || modpath == "" { + dir := filepath.Dir(filename) + mod, ok := moduleCacheByDir.Load(dir) + if ok && mod != nil { + mod := mod.(*module) + if lang == "" { + lang = mod.Go } - if *modulePath == "" { - *modulePath = mod.Module.Path + if modpath == "" { + modpath = mod.Module.Path } } } @@ -311,8 +309,8 @@ func processFile(filename string, info fs.FileInfo, in io.Reader, r *reporter, e // We also skip walking vendor directories entirely, but that happens elsewhere. if explicit || !isGenerated(file) { gformat.File(fileSet, file, gformat.Options{ - LangVersion: *langVersion, - ModulePath: *modulePath, + LangVersion: lang, + ModulePath: modpath, ExtraRules: *extraRules, }) } @@ -532,7 +530,47 @@ func gofmtMain(s *sequencer) { } } +type module struct { + Go string + Module struct { + Path string + } +} + +func loadModuleInfo(dir string) interface{} { + cmd := exec.Command("go", "mod", "edit", "-json") + cmd.Dir = dir + + // Spawning "go mod edit" will open files by design, + // such as the named pipe to obtain stdout. + // TODO(mvdan): if we run into "too many open files" errors again in the + // future, we probably need to turn fdSem into a weighted semaphore so this + // operation can acquire a weight larger than 1. + fdSem <- true + out, err := cmd.Output() + defer func() { <-fdSem }() + + if err != nil || len(out) == 0 { + return nil + } + mod := new(module) + if err := json.Unmarshal(out, mod); err != nil { + return nil + } + return mod +} + +// Written to by fileWeight, read from fileWeight and processFile. +// A present but nil value means that loading the module info failed. +// Note that we don't require the keys to be absolute directories, +// so duplicates are possible. The same can happen with symlinks. +var moduleCacheByDir sync.Map // map[dirString]*module + func fileWeight(path string, info fs.FileInfo) int64 { + dir := filepath.Dir(path) + if _, ok := moduleCacheByDir.Load(dir); !ok { + moduleCacheByDir.Store(dir, loadModuleInfo(dir)) + } if info == nil { return exclusive } diff --git a/testdata/scripts/octal-literals.txt b/testdata/scripts/octal-literals.txt index 15f483f..cc153c5 100644 --- a/testdata/scripts/octal-literals.txt +++ b/testdata/scripts/octal-literals.txt @@ -1,31 +1,33 @@ -cd module -cp foo.go foo.go.orig - # Initially, the Go language version is too low. -gofumpt foo.go -cmp stdout foo.go.orig +gofumpt -l . +! stdout . # We can give an explicitly newer version. -gofumpt -lang=1.13 foo.go -cmp stdout foo.go.golden +gofumpt -lang=1.13 -l . +stdout -count=1 'foo\.go' +stdout -count=1 'nested[/\\]nested\.go' # If we bump the version in go.mod, it should be picked up. exec go mod edit -go=1.13 +gofumpt -l . +stdout -count=1 'foo\.go' +! stdout 'nested' + +# Ensure we produce the output we expect, and that it's stable. gofumpt foo.go cmp stdout foo.go.golden - gofumpt -d foo.go.golden ! stdout . -# We can give an explicitly older version. -gofumpt -lang=v1 foo.go -cmp stdout foo.go.orig +# We can give an explicitly older version, too +gofumpt -lang=v1 -l . +! stdout . --- module/go.mod -- +-- go.mod -- module test go 1.12 --- module/foo.go -- +-- foo.go -- package p const ( @@ -34,7 +36,7 @@ const ( k = 0o_7_5_5 l = 1022 ) --- module/foo.go.golden -- +-- foo.go.golden -- package p const ( @@ -43,3 +45,16 @@ const ( k = 0o_7_5_5 l = 1022 ) +-- nested/go.mod -- +module nested + +go 1.11 +-- nested/nested.go -- +package p + +const ( + i = 0 + j = 022 + k = 0o_7_5_5 + l = 1022 +) diff --git a/testdata/scripts/workspaces.txt b/testdata/scripts/workspaces.txt index 5a3ca87..163b3d9 100644 --- a/testdata/scripts/workspaces.txt +++ b/testdata/scripts/workspaces.txt @@ -1,22 +1,16 @@ [!go1.18] skip -# Octal literal prefixes were introduced in Go 1.13. If we are outside of the -# module, language version should not be set. -gofumpt a/go112 -cmp stdout a/go112 +# Whether we run gofumpt from inside or outside a module, +# we should always use the information from its go.mod. +# We also test that we don't get confused by the presence of go.work. -cd a -gofumpt go112 -cmp stdout go113 - --- a/go112 -- -package main +gofumpt a/go112.go +cmp stdout a/go113.go -const x = 0777 --- a/go113 -- -package main +cd a +gofumpt go112.go +cmp stdout go113.go -const x = 0o777 -- go.work -- go 1.18 use ./a @@ -26,6 +20,14 @@ module a go 1.18 -- a/a.go -- package a +-- a/go112.go -- +package main + +const x = 0777 +-- a/go113.go -- +package main + +const x = 0o777 -- b/go.mod -- module b go 1.18 diff --git a/ulimit_unix_test.go b/ulimit_unix_test.go new file mode 100644 index 0000000..97ff277 --- /dev/null +++ b/ulimit_unix_test.go @@ -0,0 +1,94 @@ +// Copyright (c) 2019, Daniel Martí +// See LICENSE for licensing information + +// TODO: replace with the unix build tag once we require Go 1.19 or later +//go:build linux + +package main + +import ( + "bytes" + "fmt" + "os" + "os/exec" + "path/filepath" + "strconv" + "testing" + + qt "github.com/frankban/quicktest" + "golang.org/x/sys/unix" +) + +func init() { + // Here rather than in TestMain, to reuse the unix build tag. + if limit := os.Getenv("TEST_WITH_FILE_LIMIT"); limit != "" { + n, err := strconv.ParseUint(limit, 10, 64) + if err != nil { + panic(err) + } + rlimit := unix.Rlimit{Cur: n, Max: n} + if err := unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit); err != nil { + panic(err) + } + os.Exit(main1()) + } +} + +func TestWithLowOpenFileLimit(t *testing.T) { + // Safe to run in parallel, as we only change the limit for child processes. + t.Parallel() + + tempDir := t.TempDir() + testBinary, err := os.Executable() + qt.Assert(t, err, qt.IsNil) + + const ( + // Enough directories to run into the ulimit. + // Enough number of files in total to run into the ulimit. + numberDirs = 500 + numberFilesPerDir = 20 + numberFilesTotal = numberDirs * numberFilesPerDir + ) + t.Logf("writing %d tiny Go files", numberFilesTotal) + var allGoFiles []string + for i := 0; i < numberDirs; i++ { + // Prefix "p", so the package name is a valid identifier. + // Add one go.mod file per directory as well, + // which will help catch data races when loading module info. + dirName := fmt.Sprintf("p%03d", i) + dirPath := filepath.Join(tempDir, dirName) + err := os.MkdirAll(dirPath, 0o777) + qt.Assert(t, err, qt.IsNil) + + err = os.WriteFile(filepath.Join(dirPath, "go.mod"), + []byte(fmt.Sprintf("module %s\n\ngo 1.16", dirName)), 0o666) + qt.Assert(t, err, qt.IsNil) + + for j := 0; j < numberFilesPerDir; j++ { + filePath := filepath.Join(dirPath, fmt.Sprintf("%03d.go", j)) + err := os.WriteFile(filePath, + // Extra newlines so that "-l" prints all paths. + []byte(fmt.Sprintf("package %s\n\n\n", dirName)), 0o666) + qt.Assert(t, err, qt.IsNil) + allGoFiles = append(allGoFiles, filePath) + } + } + if len(allGoFiles) != numberFilesTotal { + panic("allGoFiles doesn't have the expected number of files?") + } + runGofmt := func(paths ...string) { + t.Logf("running with %d paths", len(paths)) + cmd := exec.Command(testBinary, append([]string{"-l"}, paths...)...) + // 256 is a relatively common low limit, e.g. on Mac. + cmd.Env = append(os.Environ(), "TEST_WITH_FILE_LIMIT=256") + out, err := cmd.Output() + var stderr []byte + if err, _ := err.(*exec.ExitError); err != nil { + stderr = err.Stderr + } + qt.Assert(t, err, qt.IsNil, qt.Commentf("stderr:\n%s", stderr)) + qt.Assert(t, bytes.Count(out, []byte("\n")), qt.Equals, len(allGoFiles)) + } + runGofmt(tempDir) + runGofmt(allGoFiles...) +} From 41c11187669d964b94dec48e09356aa02213079a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 21 Mar 2022 10:07:40 +0000 Subject: [PATCH 09/10] bump deps before the upcoming bugfix release This should help with support for Go 1.18. --- go.mod | 6 +++--- go.sum | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 150cbc7..6c2c408 100644 --- a/go.mod +++ b/go.mod @@ -6,10 +6,10 @@ require ( github.com/frankban/quicktest v1.14.2 github.com/google/go-cmp v0.5.7 github.com/rogpeppe/go-internal v1.8.1 - golang.org/x/mod v0.5.1 + golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20220209214540-3681064d5158 - golang.org/x/tools v0.1.9 + golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 + golang.org/x/tools v0.1.10 ) require ( diff --git a/go.sum b/go.sum index 24e2d04..0811dcc 100644 --- a/go.sum +++ b/go.sum @@ -17,30 +17,31 @@ github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XF github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From f04017fbc07620a2bb985db11f3d393a26c62dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 21 Mar 2022 10:20:50 +0000 Subject: [PATCH 10/10] prepare changelog for v0.3.1 And start adding links for the major changes, so any interested users can read more into each topic. We also make the release links use the "v" prefix for consistency. --- CHANGELOG.md | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a23bd2..3b15bf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Changelog -## [0.3.0] - 2022-02-22 +## [v0.3.1] - 2022-03-21 + +This bugfix release resolves a number of issues: + +* Avoid "too many open files" error regression introduced by [v0.3.0] - [#208] +* Use the `go.mod` relative to each Go file when deriving flag defaults - [#211] +* Remove unintentional debug prints when directly formatting files + +## [v0.3.0] - 2022-02-22 This is gofumpt's third major release, based on Go 1.18's gofmt. The jump from Go 1.17's gofmt should bring a noticeable speed-up, @@ -20,7 +28,7 @@ The following changes are included as well: grouped with standard library imports * `format.Options` gains a `ModulePath` field per the last bullet point -## [0.2.1] - 2021-12-12 +## [v0.2.1] - 2021-12-12 This bugfix release resolves a number of issues: @@ -29,13 +37,13 @@ This bugfix release resolves a number of issues: * Don't group interface members of different kinds * Account for leading comments in composite literals -## [0.2.0] - 2021-11-10 +## [v0.2.0] - 2021-11-10 This is gofumpt's second major release, based on Go 1.17's gofmt. The jump from Go 1.15's gofmt should bring a mild speed-up, as walking directories with `filepath.WalkDir` uses fewer syscalls. -gofumports is now removed, after being deprecated in [0.1.0]. +gofumports is now removed, after being deprecated in [v0.1.0]. Its main purpose was IDE integration; it is now recommended to use gopls, which in turn implements goimports and supports gofumpt natively. IDEs which don't integrate with gopls (such as GoLand) implement goimports too, @@ -60,7 +68,7 @@ Finally, the following changes are made to the gofumpt tool: * The `format` Go API now also applies the `gofmt -s` simplification * Add support for `//gofumpt:diagnose` comments -## [0.1.1] - 2021-03-11 +## [v0.1.1] - 2021-03-11 This bugfix release backports fixes for a few issues: @@ -68,7 +76,7 @@ This bugfix release backports fixes for a few issues: * Avoid breaking comment alignment on empty field lists * Add support for `//go-sumtype:` directives -## [0.1.0] - 2021-01-05 +## [v0.1.0] - 2021-01-05 This is gofumpt's first release, based on Go 1.15.x. It solidifies the features which have worked well for over a year. @@ -89,8 +97,12 @@ those building programs with gofumpt. Finally, this release adds the `-version` flag, to print the tool's own version. The flag will work for "master" builds too. -[0.3.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.3.0 -[0.2.1]: https://github.com/mvdan/gofumpt/releases/tag/v0.2.1 -[0.2.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.2.0 -[0.1.1]: https://github.com/mvdan/gofumpt/releases/tag/v0.1.1 -[0.1.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.1.0 +[v0.3.1]: https://github.com/mvdan/gofumpt/releases/tag/v0.3.1 +[#208]: https://github.com/mvdan/gofumpt/issues/208 +[#211]: https://github.com/mvdan/gofumpt/pull/211 + +[v0.3.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.3.0 +[v0.2.1]: https://github.com/mvdan/gofumpt/releases/tag/v0.2.1 +[v0.2.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.2.0 +[v0.1.1]: https://github.com/mvdan/gofumpt/releases/tag/v0.1.1 +[v0.1.0]: https://github.com/mvdan/gofumpt/releases/tag/v0.1.0