Skip to content

cmd/gofmt: ignores explicit file arguments not named with ".go" after CL 284138 #45859

@cherrymui

Description

@cherrymui

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

tip (6d95e5a)

Does this issue reproduce with the latest release?

No.

What did you do?

Run gofmt with an input file not named with ".go".

What did you expect to see?

Format the file, emit to stdout.

What did you see instead?

Emit nothing. No error either. The command succeeded silently.

$ cat x.go_
package p
$ gofmt x.go_
$ echo $?
0

It seems this is changed in CL https://go-review.googlesource.com/c/go/+/284138 .

The gofmt document ( https://golang.org/cmd/gofmt ) mentions

Given a file, it operates on that file; given a directory, it operates on all .go files in that directory, recursively.

For "a file" case, it does not clearly require ".go" (also not clearly mention it accepts non-".go" file). Previous versions of gofmt does work with non-".go" files.

cc @mvdan @griesemer @bcmills

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions