Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Also note that the library checks for `: %w` at the end of the format string to enable this wrapping feature. If you use "%w" anywhere else in the format string it won't work.

Yuck.



Yeah, that's the only thing I don't like about this proposal. Just seems so fragile.


The go vet command checks format strings. I expect that the command will be updated to check for correct use of %w.


What's the point of making it a format string if you are hardcoding where the % identifier goes anyway?!


The %w (or %v) identifier must be at the end for the magic to work, but you can still meaningfully format things in front of the wrapped error, e.g. fmt.Errorf("Write(%s): %w", filename, err)


Why does it need to be at the end?


forward compatibility?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: