https://go2goplay.golang.org/p/S_RDDxhTI1a
In fact, it can infer the type parameter: https://go2goplay.golang.org/p/rk7jyt3ob0v I'm not sure how useful that is though, especially because "return" inside that anonymous function will return from that anonymous function, not the outer function. https://go2goplay.golang.org/p/h6ZRnqM5cRx On Sunday, 19 September 2021 at 18:36:43 UTC+1 Haddock wrote: > Brian Candler schrieb am Sonntag, 19. September 2021 um 13:38:49 UTC+2: > >> Also, I may be missing the point, but does the following do what you want? >> https://play.golang.org/p/86DQD5QMbJ3 >> >> _, err := os.Open("non-existing") >> if pe := (&os.PathError{}); errors.As(err, &pe) { >> fmt.Println("Failed at path:", pe.Path) >> } >> > > Oh, this is cool. Thanks, Brian! When Go gets generics you can then write > something like this (pseudo code): > > _, err := os.Open("non-existing") > myerrors.As(err, os.PathError, func(pathError) { > fmt.Println("Failed at path:", pathError.Path) > }) > > And this is absolutely good enough for my purposes ;-) > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2e4eb62a-d09d-4b61-bc1d-821881344740n%40googlegroups.com.