Standard library / errors
errors.New()
Creates a non-nil error with the supplied message. Two separate calls with identical text produce distinct error values. Expected stdout: 'bad false\n'.
Formal Syntax & Structure
go syntaxgo
func New(text string) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| text | string | Message returned by Error(). |
Return Value
error
New non-nil error.
Working Example
Example Snippetgo
package main
import ( "errors" "fmt")
func main() { a, b := errors.New("bad"), errors.New("bad") fmt.Println(a, a == b)}