Replaced log.Errorf with log.Fatalf

Logger.Fatalf calls the os.Exit(1) for you
This commit is contained in:
Samuel Hawksby-Robinson 2020-06-11 17:23:12 +01:00
parent 04ad9c78f5
commit 10c06deff2
No known key found for this signature in database
GPG Key ID: 64CF99D4A64A1205
1 changed files with 3 additions and 6 deletions

View File

@ -131,8 +131,7 @@ func main() {
if len(os.Args) == 2 {
f, err := os.Open(os.Args[1])
if err != nil {
log.Errorf("error reading file: %q", err)
os.Exit(1)
log.Fatalf("error reading file: %q", err)
}
r = f
} else {
@ -141,14 +140,12 @@ func main() {
var rs Resources
if err := json.NewDecoder(r).Decode(&rs); err != nil {
log.Errorf("error parsing json: %q", err)
os.Exit(1)
log.Fatalf("error parsing json: %q", err)
}
b, err := xml.MarshalIndent(rs, "", "\t")
if err != nil {
log.Errorf("error serializing xml: %q", err)
os.Exit(1)
log.Fatalf("error serializing xml: %q", err)
}
fmt.Println(string(b))
}