go.errors
1.23.1.2
dotnet add package go.errors --version 1.23.1.2
NuGet\Install-Package go.errors -Version 1.23.1.2
<PackageReference Include="go.errors" Version="1.23.1.2" />
<PackageVersion Include="go.errors" Version="1.23.1.2" />
<PackageReference Include="go.errors" />
paket add go.errors --version 1.23.1.2
#r "nuget: go.errors, 1.23.1.2"
#:package go.errors@1.23.1.2
#addin nuget:?package=go.errors&version=1.23.1.2
#tool nuget:?package=go.errors&version=1.23.1.2
go.errors
C# package converted from the Go standard library by go2cs. Go version: 1.23.1
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).
[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.
[As] examines the tree of its first argument looking for an error that can be assigned to its second argument, which must be a pointer. If it succeeds, it performs the assignment and returns true. Otherwise, it returns false. The form
var perr *fs.PathError
if errors.As(err, &perr) {
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.
Part of the go2cs converted Go standard library. See the repository for usage and details.
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. The go2cs conversion itself is distributed under the MIT license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net9.0
- go.internal.reflectlite (>= 1.23.1.2)
- go.lib (>= 1.23.1.2)
- go.unsafe (>= 1.23.1.2)
NuGet packages (126)
Showing the top 5 NuGet packages that depend on go.errors:
| Package | Downloads |
|---|---|
|
go.io
io (net9.0 - Release) -- C# project converted from Go source |
|
|
go.time
time (net9.0 - Release) -- C# project converted from Go source |
|
|
go.strconv
strconv (net9.0 - Release) -- C# project converted from Go source |
|
|
go.fmt
fmt (net9.0 - Release) -- C# project converted from Go source |
|
|
go.strings
strings (net9.0 - Release) -- C# project converted from Go source |
GitHub repositories
This package is not used by any popular GitHub repositories.