Quantcast
Channel: Go reflect. How to check whether reflect.Type is an error type? - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by antichris for Go reflect. How to check whether reflect.Type is an...

Create a new value of the reflected type and do a type assertion:...default: typeOutValue := reflect.New(typeOut) if _, ok := typeOutValue.Interface().(*error); ok { defaultValues[i] =...

View Article



Answer by nhooyr for Go reflect. How to check whether reflect.Type is an...

You could also just use the type's name.

View Article

Answer by Volker for Go reflect. How to check whether reflect.Type is an...

In Go error is not something special. error is just a predeclared interface type so it doesn't have its own Kind in reflect.Try something along:errorInterface :=...

View Article

Go reflect. How to check whether reflect.Type is an error type?

I need to assuredly check whether a reflect.Type is an error. There is no reflect kind for error. What is the formal/idiomatic manner to check for type error in go reflect?Go Playground Full...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images