Files
tldr/pages.zh/common/go-fmt.md

24 lines
540 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# go fmt
> 格式化 Go 源文件,并打印更改的文件名。
> 更多信息:<https://pkg.go.dev/cmd/go#hdr-Gofmt__reformat__package_sources>。
- 格式化当前目录中的 Go 源文件:
`go fmt`
- 格式化您导入路径中的特定 Go 包(`$GOPATH/src`
`go fmt {{path/to/package}}`
- 格式化当前目录及所有子目录中的包(注意 `...`
`go fmt {{./...}}`
- 打印将会运行的格式化命令,而不修改任何内容:
`go fmt -n`
- 打印正在运行的格式化命令:
`go fmt -x`