golang中的byte、rune对应的基础类型
2018-07-30 23:11
316 查看
golang中存在丰富的类型,其中一部分类型如byte、rune等是基于底层的整形等基础类型实现的,熟悉类型对应的基础类型能够帮助我们了解一些coding中的小技巧,可以基于类型的基础类型直接使用。
首先了解一下一些内建类型对应的基础类型,这些都可以在源码中builtin.go中找到:
// byte is an alias for uint8 and is equivalent to uint8 in all ways. It is // used, by convention, to distinguish byte values from 8-bit unsigned // integer values. type byte = uint8 // rune is an alias for int32 and is equivalent to int32 in all ways. It is // used, by convention, to distinguish character values from integer values. type rune = int32 // iota is a predeclared identifier representing the untyped integer ordinal // number of the current const specification in a (usually parenthesized) // const declaration. It is zero-indexed. const iota = 0 // Untyped int.
如下一些小技巧:
s:="abc" cs := make([]int, 128) for _, c := range s { cs[c] += 1 }阅读更多
相关文章推荐
- 【Go入门教程4】变量(var),常量(const),内置基础类型(Boolean、数值 byte,int,rune、字符串、错误类型),分组,iota枚举,array(数值),slice(切片),map(字典),make/new操作,零值
- Java 基础类型转换byte数组, byte数组转换基础类型
- Java 基础 byte[]与各种数据类型互相转换的简单示例
- Documentum 中编号标识和type类型的对应关系表(基础)
- C++与.NET中基础类型的对应及转化
- 08.java语言基础-整数类型(byte-short-int-long)
- 2. golang 基础知识--变量、类型、关键字...
- Java中byte基础类型的特殊性
- [分享]Java中Byte与基础类型之间的转换
- C#基础蛋疼到爆的Byte类型表数范围之网兜毛衣见解……
- Java 基础类型转换byte数组, byte数组转换基础类型
- C++与.NET中基础类型的对应及转化
- C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short
- [转]java byte 数据类型(基础)
- GoLang基础数据类型--->字典(map)详解
- Java类型和本地类型对应情况(JNI基础)
- goLang中的基础类型简单应用
- C#基础蛋疼到爆的Byte类型表数范围之网兜毛衣见解……
- C的无符号数据类型int,short,byte 转为 Java对应的数据long,char,short
- java 与 ActionScript基础类型或常用类的对应关系图