Re: [go-nuts] Zero value of os.PathError causes panic when printing

2021-09-19 Thread Brian Candler
Ah OK, so fmt uses Error() if it exists? Makes sense then, thanks. BTW, I received additional (and badly-formatted) copies of your messages from "n0jfr25eemnrtjzftkt4yna3zfn...@devo.memo.com", relayed via a server 149.72.164.25 which appears to be sendgrid.com / joylabs.com. The message itself

Re: [go-nuts] Zero value of os.PathError causes panic when printing

2021-09-19 Thread 'Axel Wagner' via golang-nuts
That's because the `Error` method is declared on the pointer, not the value. So `fmt` uses its reflect-based printing for structs. On Sun, Sep 19, 2021 at 1:44 PM Brian Candler wrote: > However, the zero value itself is printable. It's only a pointer to the > zero value which panics. > https://

Re: [go-nuts] Zero value of os.PathError causes panic when printing

2021-09-19 Thread Brian Candler
However, the zero value itself is printable. It's only a pointer to the zero value which panics. https://play.golang.org/p/LhmhdeHTb0m On Sunday, 19 September 2021 at 12:34:40 UTC+1 axel.wa...@googlemail.com wrote: > I don't know if it's intentional, but I think it's expected. The panic > hap

Re: [go-nuts] Zero value of os.PathError causes panic when printing

2021-09-19 Thread 'Axel Wagner' via golang-nuts
I don't know if it's intentional, but I think it's expected. The panic happens because it tries to stringify the underlying error, which is nil. I would say the creation of a packages error types are the purview of that package. I don't think you can, generally, expect that their zero values are va