Standard library / net

net.OpError.Error()

Render the operation and underlying error as a diagnostic. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (e *OpError) Error() string

Return Value

string

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "io"  "net"  "strings")
func main() {  e := &net.OpError{Op: "read", Net: "tcp", Err: io.EOF}  fmt.Println(strings.Contains(e.Error(), "EOF"))}
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