go.errors
1.26.10.1
dotnet add package go.errors --version 1.26.10.1
NuGet\Install-Package go.errors -Version 1.26.10.1
<PackageReference Include="go.errors" Version="1.26.10.1" />
<PackageVersion Include="go.errors" Version="1.26.10.1" />
<PackageReference Include="go.errors" />
paket add go.errors --version 1.26.10.1
#r "nuget: go.errors, 1.26.10.1"
#:package go.errors@1.26.10.1
#addin nuget:?package=go.errors&version=1.26.10.1
#tool nuget:?package=go.errors&version=1.26.10.1
go.errors
C# package converted from the Go standard library by go2cs.
From C#, call this package through the static class go.errors_package; see Consuming converted Go from C#.
Package errors implements functions to manipulate errors.
The [New] function creates errors whose only content is a text message.
An error e wraps another error if e's type has one of the methods
Unwrap() error
Unwrap() []error
If e.Unwrap() returns a non-nil error w or a slice containing w, then we say that e wraps w. A nil error returned from e.Unwrap() indicates that e does not wrap any error. It is invalid for an Unwrap method to return an []error containing a nil error value.
An easy way to create wrapped errors is to call fmt.Errorf and apply the %w verb to the error argument:
wrapsErr := fmt.Errorf("... %w ...", ..., err, ...)
Successive unwrapping of an error creates a tree. The [Is] and [As] functions inspect an error's tree by examining first the error itself followed by the tree of each of its children in turn (pre-order, depth-first traversal).
See https://go.dev/blog/go1.13-errors for a deeper discussion of the philosophy of wrapping and when to wrap.
[Is] examines the tree of its first argument looking for an error that matches the second. It reports whether it finds a match. It should be used in preference to simple equality checks:
if errors.Is(err, fs.ErrExist)
is preferable to
if err == fs.ErrExist
because the former will succeed if err wraps io/fs.ErrExist.
[AsType] examines the tree of its argument looking for an error whose type matches its type argument. If it succeeds, it returns the corresponding value of that type and true. Otherwise, it returns the zero value of that type and false. The form
if perr, ok := errors.AsType[*fs.PathError](err); ok {
fmt.Println(perr.Path)
}
is preferable to
if perr, ok := err.(*fs.PathError); ok {
fmt.Println(perr.Path)
}
because the former will succeed if err wraps an *io/fs.PathError.
Copyright 2009 The Go Authors. All rights reserved. This C# package is converted from Go standard library source; use of that source is governed by a BSD-style license that can be found in the LICENSE file.
Artwork licensed under Creative Commons Attribution 3.0; see artwork attribution.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- go.internal.reflectlite (>= 1.26.10.1)
- go.lib (>= 1.26.10.1)
- go.unsafe (>= 1.26.10.1)
NuGet packages (160)
Showing the top 5 NuGet packages that depend on go.errors:
| Package | Downloads |
|---|---|
|
go.io
io (net10.0 - Release) -- C# project converted from Go source |
|
|
go.strconv
strconv (net10.0 - Release) -- C# project converted from Go source |
|
|
go.internal.oserror
internal.oserror (net10.0 - Release) -- C# project converted from Go source |
|
|
go.syscall
syscall (net10.0 - Release) -- C# project converted from Go source |
|
|
go.time
time (net10.0 - Release) -- C# project converted from Go source |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.26.10.1 | 0 | 10/26/2026 |
| 1.24.13.7 | 2,181 | 10/14/2026 |
| 1.24.13.6 | 2,139 | 10/12/2026 |
| 1.24.13.5 | 2,171 | 10/9/2026 |
| 1.24.13.4 | 2,177 | 10/6/2026 |
| 1.24.13.3 | 2,186 | 10/2/2026 |
| 1.24.13.2 | 2,132 | 9/24/2026 |
| 1.24.13.1 | 2,139 | 9/24/2026 |
| 1.23.12.3 | 2,188 | 9/8/2026 |
| 1.23.12.2 | 1,977 | 8/29/2026 |
| 1.23.12.1 | 2,073 | 8/26/2026 |
| 1.23.1.7 | 3,452 | 8/23/2026 |
| 1.23.1.6 | 2,888 | 8/11/2026 |
| 1.23.1.5 | 2,890 | 8/9/2026 |
| 1.23.1.4 | 2,839 | 8/8/2026 |
| 1.23.1.3 | 3,293 | 8/4/2026 |
| 1.23.1.2 | 3,453 | 7/27/2026 |
| 1.23.1.1 | 3,478 | 7/14/2026 |
| 0.1.0 | 1,193 | 7/8/2020 |