История изменений
Исправление derlafff, (текущая версия) :
не очень ясно, что ты хочешь
type switch
var a interface{}
switch t := a.(type) {
case string:
fmt.Println("String %v", t)
case int:
fmt.Println("Number %v", t)
case SomeInterface:
// ...
default:
fmt.Println("Another type %T", t)
}
enum
type EnumType int
const (
EnumValue1 = iota
EnumValue2
// ...
)
switch enumVar {
case EnumValue1:
fmt.Println("Value1")
case EnumValue2:
fmt.Println("Value2")
// ...
}
Исходная версия derlafff, :
type switch
var a interface{}
switch t := a.(type) {
case string:
fmt.Println("String %v", t)
case int:
fmt.Println("Number %v", t)
case SomeInterface:
// ...
default:
fmt.Println("Another type %T", t)
}