unicode - Go(golang)是否真的允许在变量名中使用 unicode 字符?

标签 unicode go

或者这是一个神话? 在任何官方文档中都看不到它的提及(它在那里,D'oh!)——当我将 Atom 与 go-plus 包一起使用时,它似乎对我不起作用。很遗憾,因为我正在做很多数学运算,而且我喜欢数学符号。

更新:我不认为任何数学符号深奥:‖ ⏋∪ 与任何表情符号相比:😀

引用官方来源的是或否答案就足够了!

更新:感谢 elithrar 的回答,我发现“拉丁字母横向点击”ǁ 是我想要的“双垂直线”的看似完美的类比。

最佳答案

根据 https://golang.org/ref/spec#Identifiers,Go 支持 一些 Unicode 类别

Identifiers name program entities such as variables and types. An identifier is a sequence of one or more letters and digits. The first character in an identifier must be a letter.

identifier = letter { letter | unicode_digit } .

上述类在规范中定义为:

unicode_letter = /* a Unicode code point classified as "Letter" */ .
unicode_digit  = /* a Unicode code point classified as "Decimal Digit" */ .

In The Unicode Standard 6.3, Section 4.5 "General Category" defines a set of character categories. Go treats those characters in category Lu, Ll, Lt, Lm, or Lo as Unicode letters, and those in category Nd as Unicode digits.

“简短”的答案是支持一些 运算符,具体取决于它们的字符类。更深奥/专业的不会。

关于unicode - Go(golang)是否真的允许在变量名中使用 unicode 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33947871/

相关文章:

javascript regex test() 无法识别丹麦语字符

python - 从格式化字符串打印 unicode

python - 在带有 unicode 文本的 python 中使用 jsbeautifier 时出错

java - 字符串不包含实体,但显示它,并且表示在替换时不会改变

sorting - 堆索引示例说明

http - GoLang HTTP GET - 400 错误请求

unicode - Elasticsearch :为捷克字符配置icu_tokenizer

multithreading - 可能/推荐在 Go 中编写事件驱动的应用程序?

xml - golang - 提取 xml 字符串中的元素

go - bigquery TIMESTAMP 字段的 Protobuf 类型