79170072

Date: 2024-11-08 12:44:18
Score: 1
Natty:
Report link

Since Go 1.22, we can use the reflect.TypeFor function to get a reflect.Type value:

func main() {
    errorType := reflect.TypeFor[error]()
    err := errors.New("foo")
    println(reflect.TypeOf(err).Implements(errorType))
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: xianyukang