From 7fd29cb024126de10a90c54427e050e7928c54b4 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 9 Mar 2020 23:23:49 -0400 Subject: content: make spacing consistent + remove comments Remove repeated blank lines, trailing spaces, trailing blank lines Remove comments from survey2018.article (only article using them). Remove blank lines between successive ".commands". For golang/go#33955. Change-Id: I90cae37a859a8e39549520569d5f10bc455415d3 Reviewed-on: https://go-review.googlesource.com/c/blog/+/222841 Reviewed-by: Ian Lance Taylor --- content/go1.13-errors.article | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'content/go1.13-errors.article') diff --git a/content/go1.13-errors.article b/content/go1.13-errors.article index 8c8c029..a3aa755 100644 --- a/content/go1.13-errors.article +++ b/content/go1.13-errors.article @@ -13,7 +13,6 @@ which produce errors that contain only a message—the built-in `error` interfac allows Go programmers to add whatever information they desire. All it requires is a type that implements an `Error` method: - type QueryError struct { Query string Err error @@ -68,7 +67,6 @@ value as a more specific type. // e.Name wasn't found } - ** Adding information Frequently a function passes an error up the call stack while adding information @@ -85,7 +83,6 @@ error except the text. As we saw above with `QueryError`, we may sometimes want to define a new error type that contains the underlying error, preserving it for inspection by code. Here is `QueryError` again: - type QueryError struct { Query string Err error @@ -99,7 +96,6 @@ error. // query failed because of a permission problem } - The `os.PathError` type in the standard library is another example of one error which contains another. * Errors in Go 1.13 @@ -123,7 +119,7 @@ the sequence of errors produced by repeated unwrapping the _error_chain_. ** Examining errors with Is and As -The Go 1.13 `errors` package includes two new functions for examining errors: `Is` and `As`. +The Go 1.13 `errors` package includes two new functions for examining errors: `Is` and `As`. The `errors.Is` function compares an error to a value. @@ -158,7 +154,6 @@ Using the `errors.Is` function, we can write this as: // err, or some error that it wraps, is a permission problem } - The `errors` package also includes a new `Unwrap` function which returns the result of calling an error's `Unwrap` method, or `nil` when the error has no `Unwrap` method. It is usually better to use `errors.Is` or `errors.As`, @@ -188,7 +183,6 @@ Wrapping an error with `%w` makes it available to `errors.Is` and `errors.As`: ... if errors.Is(err, ErrPermission) ... - ** Whether to Wrap When adding additional context to an error, either with `fmt.Errorf` or by -- cgit v1.2.3