Created
August 7, 2012 14:29
-
-
Save leejarvis/3285829 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 GetError struct { | |
Stamp time.Time | |
Message string | |
} | |
func (e *GetError) Error() string { | |
return fmt.Sprintf("[%v] %s", e.Stamp, e.Message) | |
} | |
func Get(path string) (string, error) { | |
/* SNIP */ | |
return "", &GetError{time.Now(), fmt.Sprintf("Unable to fetch path: %s", path)} | |
} | |
func main() { | |
body, err := Get("/dvma") | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(body) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment