Go中的缩进:选项卡或空格?(Indentation in Go: tabs or spaces?)
有没有一个标准的Google Go编码约定文档在哪里设置选项卡或空格是否适合缩进Go源代码? 如果没有,什么是更多(统计上)流行的选项?
什么是官方推荐? (如有) 什么是更受欢迎的选择?Is there a standard Google Go coding conventions document somewhere that sets whether tabs or spaces are preferred for indentation in Go source code? If not, what is the (statistically) more popular option?
What is the official recommendation? (if any) What is the more popular choice?最满意答案
官方的建议是使用go fmt格式化您的代码
您可以在golang.org博客或Effective Go文档中阅读更多信息:
缩进 我们使用缩进的选项卡,gofmt默认发出它们。 只有在必要时才能使用空格。
The official recommendation is formatting your code with
go fmtor using the gofmt command directly
gofmt -w .You can read more about it here on the golang.org blog, or from the Effective go document:
Indentation We use tabs for indentation and gofmt emits them by default. Use spaces only if you must.
更多推荐
发布评论