package main import ( "fmt" ) func main() { // Das leere Interface var i interface{} = "Hallo" // Type Assertion heißt in anderen Sprachen Cast -> Typ-Umwandlung // Type Assertion ohne Prüfung var s string = i.(string) fmt.Println(s) // Type Assertion mit Prüfung s2, ok := i.(string) fmt.Println(s2, "ist es ein String?", ok) // falsche Type Assertion ohne Prüfung erzeugt Panic var f float64 = i.(float64) fmt.Println(f) }