Skip to content

Commit

Permalink
better error handling, i/o
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren committed Apr 18, 2019
1 parent 38ddba2 commit 433b81a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ func runAudit(c conf.Configuration, outputFile string, outputURL string) {
}

if outputURL == "" && outputFile == "" {
y, err := yaml.Marshal(auditData)
yamlBytes, err := yaml.Marshal(auditData)
if err != nil {
panic(err)
}
fmt.Println(string(y))
os.Stdout.Write(yamlBytes)
} else {
jsonData, err := json.Marshal(auditData)
if err != nil {
Expand All @@ -202,8 +202,12 @@ func runAudit(c conf.Configuration, outputFile string, outputURL string) {
}
defer resp.Body.Close()

body, _ := ioutil.ReadAll(resp.Body)
glog.Println(string(body))
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading audit output URL response")
} else {
glog.Println(string(body))
}
}
}
}

0 comments on commit 433b81a

Please sign in to comment.