mercredi 5 avril 2023

The interface{} in golang confused me

everyone. If i have the following code. Why it will raise a error:

The code:

var i interface{}
v, ok :=i.(interface{})
fmt.Println(v, ok)

The error: <nil> false

Whether the dynamic type of a declarated interface{} var is nil alaways? but when it will be interface{}? What will be false any var's assertion to interface{} forever?





Aucun commentaire:

Enregistrer un commentaire