aboutsummaryrefslogtreecommitdiff
path: root/src/errors/example_test.go
AgeCommit message (Collapse)Author
2025-11-21errors: add examples for custom Is/As matchingSean Liao
Change-Id: Ia92dae13b6a4e9434b29d2ab3f698f6ba87b4b89 Reviewed-on: https://go-review.googlesource.com/c/go/+/713740 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-09-30errors: add AsTypeJulien Cretel
Fixes #51945 Change-Id: Icda169782e796578eba728938134a85b5827d3b6 GitHub-Last-Rev: c6ff335ee1ffb6b7975141795a4632a55247299d GitHub-Pull-Request: golang/go#75621 Reviewed-on: https://go-review.googlesource.com/c/go/+/707235 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev>
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>
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-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>
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-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-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>
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.