Go中的缩进:选项卡或空格?(Indentation in Go: tabs or spaces?)

编程入门 行业动态 更新时间:2024-10-16 16:17:30
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 fmt

or 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.

更多推荐

本文发布于:2023-08-04 10:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415228.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:空格   选项卡   Indentation   tabs   spaces

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!