git 管理下の go ファイルを対象に、テキストを一括置換して gofmt する

$ git grep -l hoge | xargs sed -i "" "s/hoge/fuga/g"
$ PAGER=cat git diff --name-only | grep ".go" | xargs gofmt -l -w

go fmt は、内部で gofmt を呼び出してる?っぽい

$ go help fmt
usage: go fmt [-n] [-x] [packages]

Fmt runs the command 'gofmt -l -w' on the packages named
by the import paths. It prints the names of the files that are modified.

For more about gofmt, see 'go doc cmd/gofmt'.
For more about specifying packages, see 'go help packages'.

The -n flag prints commands that would be executed.
The -x flag prints commands as they are executed.

The -mod flag's value sets which module download mode
to use: readonly or vendor. See 'go help modules' for more.

To run gofmt with specific options, run gofmt itself.

See also: go fix, go vet.