Golang的fallthrough与switch的坑

前端之家收集整理的这篇文章主要介绍了Golang的fallthrough与switch的坑前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

最近写Golang的是发现一个fallthrough与switch的坑:

switchvalue.(type){
caseint:
fallthrough
caseint64:
//......
}

编译就报错:

cannotfallthroughintypeswitch

WHAT????

在typeswitch 中不能使用

fallthrough

只能修改代码

switchvalue.(type){
caseint,int64:
//......
}
原文链接:https://www.f2er.com/go/188444.html

猜你在找的Go相关文章