Go - go fmt用法
go 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.
根据介绍,got fmt
可以对代码格式进行标准化调整。
用法
╭─ben at MacBook Pro in ~/go/src/github.com/goinaction/code/chapter3/tmp on master✘✘✘ 2021/08/29 - 15:34:40
╰─⠠⠵ cat go_fmt.go
package main
import "fmt"
func main() {
if err != nil { return err }
}
╭─ben at MacBook Pro in ~/go/src/github.com/goinaction/code/chapter3/tmp on master✘✘✘ 2021/08/29 - 15:34:45
╰─⠠⠵ go fmt go_fmt.go
go_fmt.go
╭─ben at MacBook Pro in ~/go/src/github.com/goinaction/code/chapter3/tmp on master✘✘✘ 2021/08/29 - 15:34:48
╰─⠠⠵ cat go_fmt.go
package main
import "fmt"
func main() {
if err != nil {
return err
}
}