aboutsummaryrefslogtreecommitdiff
path: root/src/errors
AgeCommit message (Collapse)Author
2026-01-07[release-branch.go1.25] Revert "errors: optimize errors.Join for single ↵Damien Neil
unwrappable errors" This reverts CL 635115. Reason for revert: The new behavior does not match the function documentation. For #76961 Fixes #76973 Change-Id: If2450aa4efba28c7a12887a5b306c231a836e740 Reviewed-on: https://go-review.googlesource.com/c/go/+/731981 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> (cherry picked from commit 1b3db48db7afc3fe17440af28cdeac67a0d048f1) Reviewed-on: https://go-review.googlesource.com/c/go/+/734520 Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-05-27errors: add joinError Unwrap examplejiahua wang
Change-Id: Id7489247e9bdd413f82fdf5a70197856c47abfb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/674336 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Sean Liao <sean@liao.dev>
2025-04-14errors: optimize errors.Join for single unwrappable errorsdmathieu
Change-Id: I10bbb782ca7234cda8c82353f2255eec5be588c9 GitHub-Last-Rev: e5ad8fdb802e56bb36c41b4982ed27c1e0809af8 GitHub-Pull-Request: golang/go#70770 Reviewed-on: https://go-review.googlesource.com/c/go/+/635115 Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-30errors: reference Go 1.13 article about errorsMatt T. Proud
This commit amends package errors' documentation to include a reference to the https://go.dev/blog/go1.13-errors blog article. The motivation is multi-fold, but chiefly the article includes good information about error philosophy (e.g., when to wrap), and developers who have come to Go in the intervening five years are likely not have seen this article at all given the nature of blog publishing and post fanfare. The material deserves a promotion in visibility. Change-Id: Ia6f8307784521dd59de3a3d638dbc0a7fcd445e6 GitHub-Last-Rev: 20980dd5070cde495ebb08386ae7b4cd78ccc612 GitHub-Pull-Request: golang/go#69698 Reviewed-on: https://go-review.googlesource.com/c/go/+/616341 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-05-24errors: change interface{} to any in commentkenshi kamata
Change-Id: Ibf28c4b3026019427a2485230e14929ed80a1727 Reviewed-on: https://go-review.googlesource.com/c/go/+/587255 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-04-03errors: return early for Is(nil, ...)Tobias Klauser
If err is nil it wouldn't match any given target error except for nil, so we can return early to speed up cases where Is is used without a preceding err != nil check. Change-Id: Ib33cff50453fe070f06871ce8074694c81ab787b Reviewed-on: https://go-review.googlesource.com/c/go/+/576015 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-11-21errors: clarify references to Unwrap in docOlivier Mengué
CL 535080 incorrectly links the unclear mention of Unwrap to the func Unwrap in doc for errors.Is and errors.As Instead we clarify that "Unwrap" is a reference to the "Unwrap() error" or "Unwrap() []error" methods, not to the "Unwrap(error) error" function which is also available in the package. Change-Id: I8314993932e1e7a2dc77400f74d81f3a8aa891de Reviewed-on: https://go-review.googlesource.com/c/go/+/538155 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: qiulaidongfeng <2645477756@qq.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2023-11-02errors: add available godoc linkcui fliter
Change-Id: Ie86493ebad3c3d7ea914754451985d7ee3e8e270 Reviewed-on: https://go-review.googlesource.com/c/go/+/535080 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com>
2023-08-18errors: optimize Is and As by reusing reflection of targetj178
goos: darwin goarch: amd64 pkg: errors cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz │ old │ new │ │ sec/op │ sec/op vs base │ Is-12 133.4n ± 0% 126.8n ± 3% -4.91% (p=0.001 n=10) As-12 464.1n ± 1% 307.2n ± 0% -33.80% (p=0.000 n=10) geomean 248.8n 197.4n -20.66% │ old │ new │ │ B/op │ B/op vs base │ Is-12 24.00 ± 0% 24.00 ± 0% ~ (p=1.000 n=10) ¹ As-12 40.00 ± 0% 40.00 ± 0% ~ (p=1.000 n=10) ¹ geomean 30.98 30.98 +0.00% ¹ all samples are equal │ old │ new │ │ allocs/op │ allocs/op vs base │ Is-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ As-12 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹ geomean 1.414 1.414 +0.00% ¹ all samples are equal Change-Id: I0844f3ab77e63b5f773594157dcffaffffd5e70d Reviewed-on: https://go-review.googlesource.com/c/go/+/520756 Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-16errors: add a colon after Output to make the Example in the document display ↵cui fliter
correctly Change-Id: Iaa1751c6ac0df9d5b2cb74efb16996f4eaea0503 Reviewed-on: https://go-review.googlesource.com/c/go/+/519236 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: shuang cui <imcusg@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-07-31errors: optimize *joinError's Error method for less allocation and faster ↵Jes Cok
execution Handle the case of one error at the beginning. Use unsafe.String to avoid memory allocation when converting byte slice to string. Change-Id: Ib23576f72b1d87489e6f17762be483f62ca4998a GitHub-Last-Rev: ed8003bfbcae8efd42e54895db0554c139b9d3a7 GitHub-Pull-Request: golang/go#60026 Reviewed-on: https://go-review.googlesource.com/c/go/+/493237 Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-05-25errors: add godoc linksOlivier Mengué
Change-Id: I766e656e6b967290d692313ea1391878fc21c92d Reviewed-on: https://go-review.googlesource.com/c/go/+/497375 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-03-30errors: improve the godoc for Join and UnwrapDaniel Nephin
Document that errors returned by Join always implement Unwrap []error. Explicitly state that Unwrap does not unwrap errors with an Unwrap() []error method. Change-Id: Id610345dcf43ca54a9dde157e56c5815c5112073 GitHub-Last-Rev: 7a0ec450bd0b2b38eecb5b94eaec485f4a6debbd GitHub-Pull-Request: golang/go#59301 Reviewed-on: https://go-review.googlesource.com/c/go/+/480021 Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2023-03-17errors: clarify Join documentationDavid Bendory
The previous documentation used a double-negative in describing Join behavior; this use of language could be confusing. This update removes the double-negative. Change-Id: If13e88682e865314a556e7d381143a97fa5486d9 GitHub-Last-Rev: 92b3f88a5d49229e71adafcfa7b1d01dcb7646f3 GitHub-Pull-Request: golang/go#59082 Reviewed-on: https://go-review.googlesource.com/c/go/+/477095 Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-03-11errors: add ErrUnsupportedAndy Pan
Fixes #41198 Change-Id: Ib33a11d0eb311f8e2b81de24d11df49e00b2fc81 Reviewed-on: https://go-review.googlesource.com/c/go/+/473935 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20errors: move example functions into example_test filefangguizhen
Change-Id: Ide70476698d82a51881802dd6bf05dd7abcd60e8 GitHub-Last-Rev: ddb251ded669d3dbbb96a05f4df7151c8d7c16d2 GitHub-Pull-Request: golang/go#57931 Reviewed-on: https://go-review.googlesource.com/c/go/+/462292 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-10-17errors: add test for Joinfangguizhen
Change-Id: I77c61211a488c66f1d445c0bf01e35aaf4f83565 GitHub-Last-Rev: c411a56a3b5215e6dd093be7069affb176b48dfd GitHub-Pull-Request: golang/go#56279 Reviewed-on: https://go-review.googlesource.com/c/go/+/443316 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-29errors, fmt: add support for wrapping multiple errorsDamien Neil
An error which implements an "Unwrap() []error" method wraps all the non-nil errors in the returned []error. We replace the concept of the "error chain" inspected by errors.Is and errors.As with the "error tree". Is and As perform a pre-order, depth-first traversal of an error's tree. As returns the first matching result, if any. The new errors.Join function returns an error wrapping a list of errors. The fmt.Errorf function now supports multiple instances of the %w verb. For #53435. Change-Id: Ib7402e70b68e28af8f201d2b66bd8e87ccfb5283 Reviewed-on: https://go-review.googlesource.com/c/go/+/432898 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-11-05errors: add errors.Unwrap examplejiahua wang
Change-Id: Id2336a6059f7a8d627e6c0661a4d4c05485b65f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/355589 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Cherry Mui <cherryyz@google.com> Trust: Robert Findley <rfindley@google.com>
2021-11-02errors: improve wording in As doc commentJosh Bleecher Snyder
"so" didn't have an antecedent. Change-Id: I27f7b334decea7bc34bfa3f3f2d3a79874c6fe90 Reviewed-on: https://go-review.googlesource.com/c/go/+/360797 Trust: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-19errors: mention Is methods should not call UnwrapMatt T. Proud
errors.Is internally unwraps the error until the error matches the target. Because of this, a user-authored Is method on an error type need not call errors.Unwrap on itself or the target, because that would make the unwrapping operation O(N^2). It is a subtle detail to remind authors for resource efficiency reasons. Change-Id: Ic1ba59a5bdbfe2c7cb51a2cba2537ab6de4a13ff Reviewed-on: https://go-review.googlesource.com/c/go/+/356789 Reviewed-by: Jean de Klerk <deklerk@google.com> Reviewed-by: Damien Neil <dneil@google.com> Trust: Jean de Klerk <deklerk@google.com> Trust: Damien Neil <dneil@google.com> Run-TryBot: Jean de Klerk <deklerk@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-13errors/wrap: do not call Elem() twiceVitaly Zdanevich
Change-Id: I2fe6037c45a0dfe25f946a92ff97b5e3fbd69bc0 GitHub-Last-Rev: 644d479a27c0eccfc0b37e1a560ca09e47b5a972 GitHub-Pull-Request: golang/go#44851 Reviewed-on: https://go-review.googlesource.com/c/go/+/299629 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
2020-10-20all: update references to symbols moved from os to io/fsRuss Cox
The old os references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. For #41190. Change-Id: I8f9526977867c10a221e2f392f78d7dec073f1bd Reviewed-on: https://go-review.googlesource.com/c/go/+/243907 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-04-13errors: add example for IsJonathan Amsterdam
Add ExampleIs to illustrate how errors.Is works. Updates #31716. Updates #38369. Change-Id: I1b9a6667614635aa3a5ed8b2c108d8eb6f35748b Reviewed-on: https://go-review.googlesource.com/c/go/+/228038 Reviewed-by: Damien Neil <dneil@google.com>
2020-03-09errors: fix typo in As documentationYann Salaün
Change-Id: Ia26b4457aa0780171a636df93f8d210de0278ec5 GitHub-Last-Rev: 577a6fec336010cb56a547bf2d6304fd3e0cb257 GitHub-Pull-Request: golang/go#37760 Reviewed-on: https://go-review.googlesource.com/c/go/+/222621 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-11errors: fix typo in TODO commentdavidsbond
Fixes #34846 Change-Id: I24b3e65fc96ec85b2821480e9396c9d1663611c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/200678 Run-TryBot: Johan Brandhorst <johan.brandhorst@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Johan Brandhorst <johan.brandhorst@gmail.com>
2019-09-06errors: clarify docs for when As returns falseIan Lance Taylor
Change-Id: Ic8d8399f726c1f9376499fdae92bea41632586ff Reviewed-on: https://go-review.googlesource.com/c/go/+/193602 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2019-09-04errors: fix wrong code in package docJonathan Amsterdam
You can't call Unwrap on the return value of fmt.Errorf, but you can pass the result to errors.Unwrap. Also, move the description of the Unwrap function up so the example makes sense. Fixes #34061. Change-Id: Ica07c44665c5e65deea4aa6a146fc543a5a0a99d Reviewed-on: https://go-review.googlesource.com/c/go/+/193298 Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Katie Hockman <katie@golang.org>
2019-08-27errors: document Is and As methodsJonathan Amsterdam
Add brief descriptions of why one might implement an Is or As method. Fixes #33364. Change-Id: I81a091bf564c654ddb9ef3997e780451a01efb7a Reviewed-on: https://go-review.googlesource.com/c/go/+/191338 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Andrew Bonventre <andybons@golang.org> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-26Revert "errors: add example showing a custom error with Unwrap"Andrew Bonventre
This reverts commit 739123c3a36f30af06c294741f74a26e54ee21ad. Reason for revert: broke Windows and Plan 9 builders Fixes #33828 Change-Id: I1d85c81549b1b34924fdd0ade8bf9406e5cf6555 Reviewed-on: https://go-review.googlesource.com/c/go/+/191742 Run-TryBot: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2019-08-25errors: add example showing a custom error with UnwrapJonathan Amsterdam
Change-Id: I2bddee9b460d3875911859b49528a00d318f37fc Reviewed-on: https://go-review.googlesource.com/c/go/+/184237 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-08-06errors: improve docJonathan Amsterdam
Explain wrapping and how to use Is and As in the package doc. Explain "chain" in Is and As. Updates #33364. Change-Id: Ic06362106dbd129e33dd47e63176ee5355492086 Reviewed-on: https://go-review.googlesource.com/c/go/+/188737 Reviewed-by: Rob Pike <r@golang.org>
2019-06-11errors: clarify doc for AsJonathan Amsterdam
Change-Id: I389d140e8fd2849e4dc438246add47819f6b25a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/181300 Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-06-11errors: improve As testsJonathan Amsterdam
Check the value of target after As returns true. Change-Id: I76a2b25fe825ee1dbb5f39f8f0b211c55bd25a4f Reviewed-on: https://go-review.googlesource.com/c/go/+/181299 Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-06-03errors: fix package exampleAndrew Gerrand
The example in example_test.go requires that the whole file be displayed; the addition of ExampleAs meant that only the body of the package example function was shown, rather than the surrounding context. This change moves ExampleAs to the file wrap_test.go file, restoring the package example to its former glory. Update #31716 Change-Id: Id0ea77bc06023b239a63c1d6a7c8b3c1dae91ce9 Reviewed-on: https://go-review.googlesource.com/c/go/+/179737 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org> Reviewed-by: Jean de Klerk <deklerk@google.com> Run-TryBot: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-22errors: remove mention of Wrapper interfaceDamien Neil
The Wrapper type no longer exists. Change-Id: I21051f26c6722a957295819f2f385f2bbd0db355 Reviewed-on: https://go-review.googlesource.com/c/go/+/177618 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-17errors: update As example to include else caseJean de Klerk
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>
2019-05-15errors, fmt: revert rejected changes for Go 1.13Damien Neil
Reverts the following changes: https://go.googlesource.com/go/+/1f90d081391d4f5911960fd28d81d7ea5e554a8f https://go.googlesource.com/go/+/8bf18b56a47a98b9dd2fa03beb358312237a8c76 https://go.googlesource.com/go/+/5402854c3557f87fa2741a52ffc15dfb1ef333cc https://go.googlesource.com/go/+/37f84817247d3b8e687a701ccb0d6bc7ffe3cb78 https://go.googlesource.com/go/+/6be6f114e0d483a233101a67c9644cd72bd3ae7a Partially reverts the followinng change, removing the errors.Opaque function and the errors.Wrapper type definition: https://go.googlesource.com/go/+/62f5e8156ef56fa61e6af56f4ccc633bde1a9120 Updates documentation referencing the Wrapper type. Change-Id: Ia622883e39cafb06809853e3fd90b21441124534 Reviewed-on: https://go-review.googlesource.com/c/go/+/176997 Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2019-05-13errors: remove useless condition checking in IsLE Manh Cuong
golang.org/cl/175260 fixed Is panics if target is uncomparable. It did add an useless condition checking whether target is comparable. Just remove that condition. Change-Id: I0a317056479638d209b0a0cbc7010c153558c087 Reviewed-on: https://go-review.googlesource.com/c/go/+/176497 Reviewed-by: Joan Lopez de la Franca Beltran <joanjan14@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-06errors: fix Is panics if target is uncomparableLE Manh Cuong
Fixes #31841 Change-Id: I3f068686154fd2fa5755b0df47b4eaa5c9a19107 Reviewed-on: https://go-review.googlesource.com/c/go/+/175260 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-02errors: fix comment referencing the Wrapper interfaceJacob Walker
The Unwrap function performs a type assertion looking for the Wrapper interface. The method of that interface is called Unwrap but the interface itself is called Wrapper. Change-Id: Ie3bf296f93b773d36015bcab2a0e6585d39783c7 GitHub-Last-Rev: 32b1a0c2f8bf8f3eaebf6de252571d82313e86e0 GitHub-Pull-Request: golang/go#31794 Reviewed-on: https://go-review.googlesource.com/c/go/+/174917 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-10errors: return false if nil error is passed to AsAhsun Ahmed
Fixes #30970 Change-Id: I333676b55a2364e329fffeafca8fc57d45a0b84b Reviewed-on: https://go-review.googlesource.com/c/go/+/168598 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org> Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-14fmt: make type of fmt.Errorf the same as that of errors.NewMarcel van Lohuizen
This applies only for cases where %w is not used. The purpose of this change is to reduce test failures where tests depend on these two being the same type, as they previously were. Change-Id: I2dd28b93fe1d59f3cfbb4eb0875d1fb8ee699746 Reviewed-on: https://go-review.googlesource.com/c/go/+/167402 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2019-03-14errors: improve performance of NewMarcel van Lohuizen
See Issue #29382 and Issue #30468. Improvements in this CL: name old time/op new time/op delta New-8 352ns ± 2% 225ns ± 5% -36.04% (p=0.008 n=5+5) Improvements together with moving to 1 uintptr: name old time/op new time/op delta New-8 475ns ± 3% 225ns ± 5% -52.59% (p=0.008 n=5+5) Change-Id: I9d69a14e5e10a6498767defb7d5f26ceedcf9ba5 Reviewed-on: https://go-review.googlesource.com/c/go/+/167401 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2019-03-14errors: record only single frameMarcel van Lohuizen
See Issue #29382 and Issue #30468. 3 frames are no longer needed as of https://go-review.googlesource.com/c/go/+/152537/ name old time/op new time/op delta New-8 475ns ± 3% 352ns ± 2% -25.87% (p=0.008 n=5+5) Errorf/no_format-8 661ns ± 4% 558ns ± 2% -15.63% (p=0.008 n=5+5) Errorf/with_format-8 729ns ± 6% 626ns ± 2% -14.23% (p=0.008 n=5+5) Errorf/method:_mytype-8 1.00µs ± 9% 0.84µs ± 2% -15.94% (p=0.008 n=5+5) Errorf/method:_number-8 1.25µs ± 7% 1.04µs ± 2% -16.38% (p=0.008 n=5+5) Change-Id: I30377e769b3b3be623f63ecbe365f8950ca08dda Reviewed-on: https://go-review.googlesource.com/c/go/+/167400 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2019-02-27errors: add Unwrap, Is, and AsMarcel van Lohuizen
Unwrap, Is and As are as defined in proposal Issue #29934. Also add Opaque for enforcing an error cannot be unwrapped. Change-Id: I4f3feaa42e3ee7477b588164ac622ba4d5e77cad Reviewed-on: https://go-review.googlesource.com/c/163558 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2019-02-27errors: add Frame and Formatter/Printer interfacesMarcel van Lohuizen
errors.New now implements Formatter and includes Frame information that is reported when detail is requested. Partly implements proposal Issue #29934. Change-Id: Id76888d246d7d862595b5e92d517b9c03f23a7a6 Reviewed-on: https://go-review.googlesource.com/c/163557 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2016-03-01all: make copyright headers consistent with one space after periodBrad Fitzpatrick
This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.