Standard library / net/url
url.Error.Unwrap()
Return the underlying error for errors.Is and errors.As. Expected stdout: 'true true\n'.
Formal Syntax & Structure
go syntaxgo
func (e *Error) Unwrap() errorReturn Value
error
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "context" "errors" "fmt" "net/url")
func main() { e := &url.Error{Err: context.Canceled} fmt.Println(errors.Is(e, context.Canceled), e.Unwrap() == context.Canceled)}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}