Go语言中文网 为您找到相关结果 3

golang 中的 类型判断

golang 中的 类型判断 类似于javascript中typeof 和 java中 instanceof 比如 var a interface{} newA,ok:=a.(string) 如果ok 是 true 则说明 变量a 是字符串类型,而newA就是string类型的变量,a的实际值 a.(type) 返回的是 a的 类型, 注意他返回的不是一个 字符串表示 string int 这样表示a的类型 a.(type)是和switch 搭配使用的 switch vtype:=v.(type){ case string: xxxxxxxxxxxxxxxxxx case int: xxxxxxxxxxxxxxxx case xxxxxx: xxxxxxxxxxxxx case []inte...阅读全文

博文 2014-10-04 19:26:13 suncaishen