Skip to content
Snippets Groups Projects
Commit 43a66e40 authored by Alex Ellis's avatar Alex Ellis
Browse files

Error handling in sample

parent 22b3e73b
No related branches found
No related tags found
No related merge requests found
......@@ -6,13 +6,23 @@ import (
"os"
"strconv"
"time"
"log"
)
func main() {
input, _ := ioutil.ReadAll(os.Stdin)
fmt.Println("Stashing request")
input, err := ioutil.ReadAll(os.Stdin)
if err != nil {
log.Fatalf("Cannot read input %s.\n", err)
return
}
now := time.Now()
stamp := strconv.FormatInt(now.UnixNano(), 10)
ioutil.WriteFile(stamp+".txt", input, 0644)
writeErr := ioutil.WriteFile(stamp+".txt", input, 0644)
if writeErr != nil {
log.Fatalf("Cannot write input %s.\n", err)
return
}
fmt.Printf("Stashing request: %s.txt\n", stamp)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment