Standard library / net

net.DNSConfigError.Unwrap()

Return the wrapped error, allowing errors.Is and errors.As to traverse it. Synthetic legacy example. Expected stdout: 'true true\n'.

Formal Syntax & Structure

go syntaxgo
func (e *DNSConfigError) Unwrap() error

Return Value

error

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "errors"  "fmt"  "net")
func main() {  e := &net.DNSConfigError{Err: errors.New("demo")}  fmt.Println(e.Unwrap() == e.Err, errors.Is(e, e.Err))}
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)  }}
Go Reference