]> Cypherpunks.ru repositories - gostls13.git/commit
errors: update As example to include else case
authorJean de Klerk <deklerk@google.com>
Fri, 17 May 2019 00:15:39 +0000 (18:15 -0600)
committerEmmanuel Odeke <emm.odeke@gmail.com>
Fri, 17 May 2019 16:21:05 +0000 (16:21 +0000)
commit703fb665d68ac96ae193891ffae2774c2a3deb4b
tree7bf67273afad3b95a13393c633da605a08161354
parentf35338582d0e0e7047fa45be3cb8064c43c50f25
errors: update As example to include else case

The current example illustrates using As when the error is able to be
interpreted as an os.PathError, but elides the "else" case. This CL adds the
small extra else case to make it clear that it's not safe to assume As will
return true.

This CL also squash the err instantiation and the err nil check into one line
for brevity.

Change-Id: I3d3ab483ffb38fb2788d0498b3f03229a87dd7c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/177717
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/errors/example_test.go