complete string constant error example

Stephan Renatus 2019-07-26 16:42:46 +02:00
parent af4e0ae9a0
commit 53d589dd66

@ -49,6 +49,10 @@ If you want to create a constant string error, you can use a named type string:
type errorConst string
const ErrTooManyErrors errorConst = "too many errors found."
type (e errorConst) Error() string {
return string(e)
}
```
Calling code would test for a special type of `error` by using a type switch: