,所以我在这里介意自己的生意,编码...然后进行静态检查,打我的黄色线(我们都知道和讨厌)说 -
type assertion to the same type: (*valPtr) already has type interface{} (S1040)
for _, row := range table {
for _, colVal := range row {
valPtr := colVal.(*interface{})
val := (*valPtr).(interface{})
switch v := val.(type) {
case string:
fmt.Printf("%s\t", v)
case int64, int32, int, float32, float64:
fmt.Printf("%d\t", v)
default:
fmt.Printf("unknown type\t")
}
}
fmt.Println()
}
我的理解和逻辑因此,我最初从接口到指针转到接口(因为那是存储在(对?)内的类型)。接下来,我将指针指向接口并将其施放到接口 - 这样我就可以做
switch val.(type)
。当我要发布这个问题时,正好击中了我...
type assertion to the same type: (*valPtr) already has type interface{} (S1040)
(类型为
valPtr
)你为什么要把它扔到*interface{}
(again
)??