> They did introduce panic, they just discourage anyone outside the language design team from taking advantage of it.
The guidance I remember when I was trying out go and researching idiomatic Go style was not “don’t use panic in your code” but “don’t expose panics [other than the ‘always and everytime fatal’ kind] across the public API surface of your code”.
Basically, if someone other than the code owner would want to react to it, it should be converted to an error return before hitting the code consuming your library.
The guidance I remember when I was trying out go and researching idiomatic Go style was not “don’t use panic in your code” but “don’t expose panics [other than the ‘always and everytime fatal’ kind] across the public API surface of your code”.
Basically, if someone other than the code owner would want to react to it, it should be converted to an error return before hitting the code consuming your library.