Eri*_*lun 105 formatting indentation go
是否有一个标准的Google Go编码约定文档,用于设置是否首选标签或空格以用于Go源代码中的缩进?如果没有,那么(统计上)受欢迎的选项是什么?
ANi*_*sus 172
官方建议使用格式化代码
go fmt
Run Code Online (Sandbox Code Playgroud)
或直接使用gofmt命令
gofmt -w .
Run Code Online (Sandbox Code Playgroud)
你可以阅读更多关于它在这里的golang.org博客,或者从有效去文件:
缩进
我们使用制表符进行缩进,默认情况下gofmt会发出缩进.仅在必要时使用空格.
Int*_*net 20
根据http://golang.org/src/cmd/gofmt/doc.go,默认值为:
编辑:底部的原始答案现在不正确.链接源文件的正确部分(当前25/07/2014)是:
Gofmt格式Go程序.
它使用制表符(宽度= 8)进行缩进,使用空格进行对齐.
原始答案(不建议使用):
Formatting control flags:
-comments=true
Print comments; if false, all comments are elided from the output.
-tabs=true
Indent with tabs; if false, spaces are used instead.
-tabwidth=8
Tab width in spaces.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
55607 次 |
| 最近记录: |