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

1
2
3
4
5
6
switch  value.(type) {
     case  int :
         fallthrough
     case  int64:
         //......
}

编译就报错:

1
cannot fallthrough in type  switch

WHAT????

在type switch 中不能使用

1
fallthrough

只能修改代码:

1
2
3
4
switch  value.(type) {
     case  int  , int64:
         //......
}