Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created August 7, 2012 14:29
Show Gist options
  • Save leejarvis/3285829 to your computer and use it in GitHub Desktop.
Save leejarvis/3285829 to your computer and use it in GitHub Desktop.
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