7

【笔记】利用类型断言确定数据类型

 1 year ago
source link: https://blog.loli.fj.cn/2023/05/16/%E5%88%A9%E7%94%A8%E7%B1%BB%E5%9E%8B%E6%96%AD%E8%A8%80%E7%A1%AE%E5%AE%9A%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

【笔记】利用类型断言确定数据类型

2023-05-16

Go语言利用类型断言确定数据类型

var 接口类型变量 interface{} = 数据
switch 接口类型变量.(type) {
case bool:
...
case float32, float64:
...
case int, int32, int64:
...
case string:
...
case *bool:
...
case *float32, *float64:
...
case *int, *int32, *int64:
...
case *string:
...
default:
...
}

哔哩哔哩——尚硅谷


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK