Skip to content

"gofmt -d" should have non-zero exit if there is a diff #38551

Closed
@belm0

Description

@belm0

What version of Go are you using (go version)?

$ go version
go version go1.13.4 darwin/amd64

What did you do?

$ gofmt -d .
(... diff ...)
$ echo $?
0

What did you expect to see?

Exit value of 1, since there is a diff.

Presence of a diff is the error case, meaning that the code requires formatting. Then for example, makefile targets to check formatting can simply be "gofmt -d ." and do the right thing.

What did you see instead?

exit value of 0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions