吐出代码格式错误,而不是在 golang 中实际格式化
Spit out code formatting errors than actually formatiing in golang
我正在处理大型 go 代码库,而 go 代码的格式似乎不正确。
我想知道 go 中是否有一个选项会以某种方式断言我需要更改代码样式的地方。我没有使用任何 IDE。 go fmt
完成这项工作,但我不希望自动处理样式。我找不到任何可以传递给 go fmt
来执行相同操作的选项/参数。
有什么方法可以(有点)干掉 运行 go fmt 并吐出格式错误或使用任何其他实用程序来做到这一点?
go fmt
命令运行gofmt命令。直接使用 gofmt
命令以获得更多控制。
# use -d flag to print difference between file at path and formatted file
gofmt -d path
# no flags prints the formatted file to stdout. This is the dry run.
gofmt path
我正在处理大型 go 代码库,而 go 代码的格式似乎不正确。
我想知道 go 中是否有一个选项会以某种方式断言我需要更改代码样式的地方。我没有使用任何 IDE。 go fmt
完成这项工作,但我不希望自动处理样式。我找不到任何可以传递给 go fmt
来执行相同操作的选项/参数。
有什么方法可以(有点)干掉 运行 go fmt 并吐出格式错误或使用任何其他实用程序来做到这一点?
go fmt
命令运行gofmt命令。直接使用 gofmt
命令以获得更多控制。
# use -d flag to print difference between file at path and formatted file
gofmt -d path
# no flags prints the formatted file to stdout. This is the dry run.
gofmt path