In Go, a type assertion is used to extract the underlying concrete value of an interface.

// value has an interface type
// typeName is the expected type
value.(typeName)
 
// comma ok idiom
var i interface{} = 42
s, ok := i.(string)
if ok {
    fmt.Println(s) // not executed
} else {
    fmt.Println("i is not a string") // output: i is not a string
}
 
//