Skip to content

Instantly share code, notes, and snippets.

@ceaksan
Created March 9, 2018 08:02
Show Gist options
  • Save ceaksan/67df6efd51d9992db74abb7cbc251ebb to your computer and use it in GitHub Desktop.
Save ceaksan/67df6efd51d9992db74abb7cbc251ebb to your computer and use it in GitHub Desktop.
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