mirror of
https://github.com/goplus/llgo.git
synced 2025-09-26 19:51:21 +08:00
22 lines
420 B
Go
22 lines
420 B
Go
package main
|
|
|
|
// New returns an error that formats as the given text.
|
|
// Each call to New returns a distinct error value even if the text is identical.
|
|
func New(text string) error {
|
|
return &errorString{text}
|
|
}
|
|
|
|
// errorString is a trivial implementation of error.
|
|
type errorString struct {
|
|
s string
|
|
}
|
|
|
|
func (e *errorString) Error() string {
|
|
return e.s
|
|
}
|
|
|
|
func main() {
|
|
err := New("an error")
|
|
println(err.Error())
|
|
}
|