Standard library / net/http

http.ProtocolError.Error()

Returns the ErrorString field as the error message. Expected stdout: 'demo\n'.

Formal Syntax & Structure

go syntaxgo
func (pe *ProtocolError) Error() string

Return Value

string

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/http")
func main() { e := &http.ProtocolError{ErrorString: "demo"}; fmt.Println(e.Error()) }
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