去const命名约定 [英] Go naming conventions for const

查看:119
本文介绍了去const命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图确定Golang中 const 的名称是否有命名约定。



我个人倾向于遵循C风格并以大写形式书写它们,但我在此页面上找不到任何东西 http://golang.org/doc/effective_go.html ,它似乎列出了该语言的一些命名约定。

解决方案

标准库使用camel-case,所以我建议你也这样做。第一个字母是大写或小写,取决于您是否要导出常量。



一些例子:


  • md5.BlockSize

  • os.O_RDONLY 是一个例外,因为它是直接从POSIX借来的。

  • os.PathSeparator

>

I'm trying to determine whether there is a naming convention for the names of const in Golang.

I personally would tend to follow the C style and write them in upper case, but I haven't found anything on this page http://golang.org/doc/effective_go.html which seems to list some naming conventions for the language.

解决方案

The standard library uses camel-case, so I advise you do that as well. The first letter is uppercase or lowercase depending on whether you want to export the constant.

A few examples:

  • md5.BlockSize
  • os.O_RDONLY is an exception because it was borrowed directly from POSIX.
  • os.PathSeparator

这篇关于去const命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆