| 1 |
package w |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
"log" |
| 6 |
) |
| 7 |
|
| 8 |
type CustomError struct { |
| 9 |
Msg string |
| 10 |
} |
| 11 |
|
| 12 |
func (e CustomError) Error() string { |
| 13 |
return e.Msg |
| 14 |
} |
| 15 |
|
| 16 |
type E int |
| 17 |
|
| 18 |
func (*E) Error() string { |
| 19 |
return "" |
| 20 |
} |
| 21 |
|
| 22 |
func PrintfTests() { |
| 23 |
fmt.Errorf("%w", &CustomError{Msg: "custom error"}) |
| 24 |
fmt.Errorf("%w", CustomError{Msg: "custom error"}) |
| 25 |
var err *CustomError |
| 26 |
fmt.Errorf("%w", err) |
| 27 |
|
| 28 |
var e *E |
| 29 |
fmt.Errorf("%w", e) |
| 30 |
|
| 31 |
log.Printf("%w", &CustomError{Msg: "custom error"}) |
| 32 |
} |