s, ok := v.(string) if !ok { // the assertion failed. } // OR // switch t := v.(type) { case string: // t is a string case int : // t is an int default: // t is some other type that we didn't name. }