@lupyuen you might want to use the

x, ok := y.(type)
if !ok {
return fmt.Errorf("type assertion failed for: %v", x)
}

style of type assertions. by using the form with two return values you can prevent panics and instead return an error if you have malformed input data.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.