Skip to content

Releases: mvdan/gofumpt

v0.7.0

16 Aug 22:24
v0.7.0
86bffd6
Compare
Choose a tag to compare

This release is based on Go 1.23.0's gofmt, and requires Go 1.22 or later.

The following changes are included:

  • format.Options.LangVersion now requires Go version strings following go/version
  • Group internal/... imported packages as standard library - #307

Binaries built on go version go1.23.0 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v0.7.0"

Consider becoming a sponsor if you benefit from the work that went into this release!

v0.6.0

28 Jan 22:39
v0.6.0
636d7a7
Compare
Choose a tag to compare

This release is based on Go 1.21's gofmt, and requires Go 1.20 or later.

The following changes are included:

  • Support go version strings from newer go.mod files - #280
  • Consider simple error checks even if they use the = operator - #271
  • Ignore //line directives to avoid panics - #288

Binaries built on go version go1.21.6 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v0.6.0"

Consider becoming a sponsor if you benefit from the work that went into this release!

v0.5.0

09 Apr 21:03
v0.5.0
fd93f1d
Compare
Choose a tag to compare

This release is based on Go 1.20's gofmt, and requires Go 1.19 or later.

The biggest change in this release is that we now vendor copies of the packages go/format, go/printer, and go/doc/comment on top of cmd/gofmt itself. This allows for each gofumpt release to format code in exactly the same way no matter what Go version is used to build it, as Go versions can change those three packages in ways that alter formatting behavior.

This vendoring adds a small amount of duplication when using the mvdan.cc/gofumpt/format library, but it's the only way to make gofumpt versions consistent in their behavior and formatting, just like gofmt.

The jump to Go 1.20's go/printer should also bring a small performance improvement, as we contributed patches to make printing about 25% faster:

The following changes are included as well:

  • Skip testdata dirs by default like we already do for vendor - #260
  • Avoid inserting newlines incorrectly in some func signatures - #235
  • Avoid joining some comments with the previous line - #256
  • Fix gofumpt -version for release archives - #253

Binaries built on go version go1.20.3 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v0.5.0"

Consider becoming a sponsor if you benefit from the work that went into this release!

v0.4.0

27 Sep 09:45
Compare
Choose a tag to compare

This release is based on Go 1.19's gofmt, and requires Go 1.18 or later.
We recommend building gofumpt with Go 1.19 for the best formatting results.

The jump from Go 1.18 brings diffing in pure Go, removing the need to exec diff,
and a small parsing speed-up thanks to go/parser.SkipObjectResolution.

The following formatting fixes are included as well:

  • Allow grouping declarations with comments - #212
  • Properly measure the length of case clauses - #217
  • Fix a few crashes found by Go's native fuzzing

Binaries built on go version go1.19.1 linux/amd64 via a shell script.

Consider becoming a sponsor if you benefit from the work that went into this release!

v0.3.1

21 Mar 10:45
Compare
Choose a tag to compare

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

Binaries built on go version go1.18 linux/amd64 via a shell script.

Consider becoming a sponsor if you benefit from the work that went into this release!

v0.3.0

22 Feb 17:27
Compare
Choose a tag to compare

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, as the tool can now format many files concurrently. On an 8-core laptop, formatting a large codebase is 4x as fast.

The following formatting rules are added:

  • Functions should separate ) { where the indentation helps readability
  • Field lists should not have leading or trailing empty lines

The following changes are included as well:

  • Generated files are now fully formatted when given as explicit arguments
  • Prepare for Go 1.18's module workspaces, which could cause errors
  • Import paths sharing a prefix with the current module path are no longer grouped with standard library imports
  • format.Options gains a ModulePath field per the last bullet point

A special thanks to @Oiyoo for his recent contributions as well πŸŽ‰

Binaries built on go version go1.17.7 linux/amd64 via a shell script.

Consider becoming a sponsor if you benefit from the work that went into this release!

v0.2.1

16 Dec 15:24
Compare
Choose a tag to compare

This bugfix release resolves a number of issues:

  • Add deprecated flags -s and -r once again, now giving useful errors
  • Avoid a panic with certain function declaration styles
  • Don't group interface members of different kinds
  • Account for leading comments in composite literals

Binaries built on go version go1.17.5 linux/amd64 via a shell script.

Consider becoming a sponsor if you benefit from the work that went into this release!

v0.2.0

10 Nov 17:09
Compare
Choose a tag to compare

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 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, so it is safe to use gofumpt as their "format on save" command. See the installation instructions for more details.

The following formatting rules are added:

  • Composite literals should not have leading or trailing empty lines
  • No empty lines following an assignment operator
  • Functions using an empty line for readability should use a ) { line instead
  • Remove unnecessary empty lines from interfaces

Finally, the following changes are made to the gofumpt tool:

  • Initial support for Go 1.18's type parameters is added
  • The -r flag is removed in favor of gofmt -r
  • The -s flag is removed as it is always enabled
  • Vendor directories are skipped unless given as explicit arguments
  • The added rules are not applied to generated Go files
  • The format Go API now also applies the gofmt -s simplification
  • Add support for //gofumpt:diagnose comments

Binaries built on go version go1.17.3 linux/amd64 via a shell script.

Consider becoming a sponsor if you benefit from the work that went into this release!

v0.1.1

11 Mar 09:40
Compare
Choose a tag to compare

This bugfix release backports fixes for a few issues:

  • Keep leading empty lines in func bodies if they help readability
  • Avoid breaking comment alignment on empty field lists
  • Add support for //go-sumtype: directives

Binaries built on go version go1.16.1 linux/amd64 via a shell script.

v0.1.0

05 Jan 14:52
Compare
Choose a tag to compare

This is gofumpt's first release, based on Go 1.15.x. It solidifies the features which have worked well for over a year.

This release will be the last to include gofumports, the fork of goimports which applies gofumpt's rules on top of updating the Go import lines. Users who were relying on goimports in their editors or IDEs to apply both gofumpt and goimports in a single step should switch to gopls, the official Go language server. It is supported by many popular editors such as VS Code and Vim, and already bundles gofumpt support. Instructions are available in the README.

gofumports also added maintenance work and potential confusion to end users. In the future, there will only be one way to use gofumpt from the command line. We also have a Go API for 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.

Binaries built on go version go1.15.6 linux/amd64 via a shell script.

Consider becoming a sponsor if you benefit from the work that went into this release!