tlog.app/go/errors@v0.9.0/unsafe.go (about)

     1  //go:build go1.13
     2  // +build go1.13
     3  
     4  //nolint:godot
     5  package errors
     6  
     7  //nolint:gci
     8  import (
     9  	_ "errors" // for go:linkname
    10  	_ "unsafe" // for go:linkname
    11  )
    12  
    13  //go:linkname Is errors.Is
    14  
    15  // Is reports whether any error in err's chain matches target.
    16  //
    17  // The chain consists of err itself followed by the sequence of errors obtained by
    18  // repeatedly calling Unwrap.
    19  //
    20  // An error is considered to match a target if it is equal to that target or if
    21  // it implements a method Is(error) bool such that Is(target) returns true.
    22  //
    23  // link to stdlib errors.Is
    24  func Is(err, target error) bool
    25  
    26  //go:linkname As errors.As
    27  
    28  // As finds the first error in err's chain that matches target, and if so, sets
    29  // target to that error value and returns true.
    30  //
    31  // The chain consists of err itself followed by the sequence of errors obtained by
    32  // repeatedly calling Unwrap.
    33  //
    34  // An error matches target if the error's concrete value is assignable to the value
    35  // pointed to by target, or if the error has a method As(interface{}) bool such that
    36  // As(target) returns true. In the latter case, the As method is responsible for
    37  // setting target.
    38  //
    39  // As will panic if target is not a non-nil pointer to either a type that implements
    40  // error, or to any interface type. As returns false if err is nil.
    41  //
    42  // link to stdlib errors.As
    43  func As(err error, target interface{}) bool
    44  
    45  //go:linkname Unwrap errors.Unwrap
    46  
    47  // Unwrap returns the result of calling the Unwrap method on err, if err's
    48  // type contains an Unwrap method returning error.
    49  // Otherwise, Unwrap returns nil.
    50  func Unwrap(err error) error