Created
March 9, 2018 08:02
-
-
Save ceaksan/67df6efd51d9992db74abb7cbc251ebb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
type MyError struct { | |
When time.Time | |
What string | |
} | |
func (e *MyError) Error() string { | |
return fmt.Sprintf("at %v, %s", | |
e.When, e.What) | |
} | |
func run() error { | |
return &MyError{ | |
time.Now(), | |
"it didn't work", | |
} | |
} | |
func main() { | |
if err := run(); err != nil { | |
fmt.Println(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment