=Start=

搜索关键字:

golang single quotes 
golang double quotes 
golang back quotes

参考结果:

结论写在最前:在Go语言中不倾向于使用单引号来表示字符串,请根据需要使用双引号或反引号。


一个Go语言字符串是一个任意字节的常量序列。Go语言的字符串类型在本质上就与其他语言的字符串类型不同。Java的String、C++的std::string以及python3的str类型都只是定宽字符序列,而 Go语言的字符串是一个用UTF-8编码的变宽字符序列,它的每一个字符都用一个或多个字节表示 

Go语言中的字符串字面量使用 双引号 或 反引号 来创建 

  • 双引号用来创建 可解析的字符串字面量 (支持转义,但不能用来引用多行);
  • 反引号用来创建 原生的字符串字面量 ,这些字符串可能由多行组成(不支持任何转义序列),原生的字符串字面量多用于书写多行消息、HTML以及正则表达式

There are two forms: raw string literals and interpreted string literals.

  • Raw string literals are character sequences between back quotes, as in foo .
  • Interpreted string literals are character sequences between double quotes, as in “bar”.

A rune literal represents a rune constant, an integer value identifying a Unicode code point. A rune literal is expressed as one or more characters enclosed in single quotes, as in ‘x’ or ‘\n’. Within the quotes, any character may appear except newline and unescaped single quote. A single quoted character represents the Unicode value of the character itself, while multi-character sequences beginning with a backslash encode values in various formats.

=

根据我找到的资料以及碰到的情况来看, Go语言的单引号一般用来表示「rune literal」 ,即——码点字面量。

参考链接:
  • https://golang.org/ref/spec#String_literals
  • https://golang.org/ref/spec#Rune_literals
  • http://teapottable.com/blog/starting-out-with-go-lang/

=EOF=

最新文章

  1. php报错 ----> Call to undefined function imagecreatetruecolor()
  2. Atitit. 构造ast 语法树的总结attilax oao 1. Ast结构树形12. ast view (自是个160k的jar )22.1. 多条语句ast结构22.2. 变量定义 int b,c; 的ast结构22.3. 方法调用meth1(a=1,b=2,c=3);  的ast结构23. 误解的问题33.1. 语法书子能是个二叉树,实际上多叉树越好..33.2. 非要不个ast放到个s
  3. IOS下自定义click事件使用alert引发的血案
  4. JavaScript基础--小案例:在网页指定位置弹出错误信息(十二)
  5. SQL优化(zhuan)
  6. java.lang.UnsatisfiedLinkError: Couldn't load vi_voslib from loader dalvik.system.PathClassLoader
  7. mysql 源代码学习 博客 [lock..]
  8. HDU 4668 Finding string (解析字符串 + KMP)
  9. Ubuntu12.04安装配置Theano
  10. 添加一个Application Framework Service
  11. Mqtt学习指南
  12. deepin linux学习笔记
  13. 使用 ffmpeg nginx rtmp 搭建实时流处理平台
  14. http之cdn介绍
  15. C# 之 索引器
  16. .NetCore下使用Prometheus实现系统监控和警报 (五)进阶自定义收集指标 之 Counter
  17. 一张图作为Python入门(图片来自网络)
  18. 【repost】JavaScript运动框架之速度时间版本
  19. Linux命令网络命令之netstat
  20. easyui-textbox 只读设置取消

热门文章

  1. Django--------问题:在terminal命令行创建超级用户时入到password时输入为什么没有反应?
  2. SQL DML 和 DDL
  3. hibernate框架的搭建与简单实现增删改
  4. 【bzoj4260】Codechef REBXOR Trie树
  5. 常用jar包下载地址汇总
  6. [USACO13JAN] Cow Lineup (单调队列,尺取法)
  7. C#创建Graphics对象的方法
  8. .net IntPtr ==interoperable pointer
  9. input弹出的手机键盘搜索事件
  10. 部分转 php kafka