GOlang学习

Golang 学习

编译命令build

在cmd 中输入go build helloworld.go,将在当前目录下生成helloworld.exe。

map注意点

  • 使用for range访问map时,每次访问的次序都是随机的。每次使用for range访问map,都会得到不同的结果。
  • go中的map 实现是哈希表hashmap。源码阅读文件:
    (GOROOT/Go/src/runtime/hashmap.go)

rune

rune 是int32 的别名。用UTF-8 进行编码。这个类型在什么时候使用呢?例如需要遍
历字符串中的字符。可以循环每个字节(仅在使用US ASCII 编码字符串时与字符等价,
而它们在Go 中不存在!)。因此为了获得实际的字符,需要使用rune 类型。

在UTF-8 世界的字符有时被称作runes。通常,当人们讨论字符时,多数是指8 位字符。UTF-8 字符可能会有32 位,称作rune。

转载自:
http://blog.163.com/hehaifeng1984@126/blog/static/690011362015715935516/

go语言数据类型与c语言相应类型对应关系

char -->  C.char -->  byte
signed char -->  C.schar -->  int8
unsigned char -->  C.uchar -->  uint8
short int -->  C.short -->  int16
short unsigned int -->  C.ushort -->  uint16
int -->  C.int -->  int
unsigned int -->  C.uint -->  uint32
long int -->  C.long -->  int32 or int64
long unsigned int -->  C.ulong -->  uint32 or uint64
long long int -->  C.longlong -->  int64
long long unsigned int -->  C.ulonglong -->  uint64
float -->  C.float -->  float32
double -->  C.double -->  float64
wchar_t -->  C.wchar_t  -->  
void * -> unsafe.Pointer
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值