From fa02c0948ec73852cb6b978e1c205a0b8cb144f2 Mon Sep 17 00:00:00 2001 From: Xavier Petit <32063953+xpetit@users.noreply.github.com> Date: Mon, 13 Apr 2020 19:07:17 +0200 Subject: [PATCH] err.Error() => err (in main sources) return/log.Fatal => panic --- tests/go/cat_test.go | 2 +- tests/go/solutions/cat/main.go | 7 ++----- tests/go/solutions/displayfile/main.go | 2 +- tests/go/solutions/raid3/raid1aProg/raid1a.go | 2 +- tests/go/solutions/raid3/raid1bProg/raid1b.go | 2 +- tests/go/solutions/raid3/raid1cProg/raid1c.go | 2 +- tests/go/solutions/raid3/raid1dProg/raid1d.go | 2 +- tests/go/solutions/raid3/raid1eProg/raid1e.go | 2 +- tests/go/solutions/range/main.go | 2 +- tests/go/solutions/reverserange/main.go | 2 +- tests/go/solutions/ztail/main.go | 2 +- 11 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/go/cat_test.go b/tests/go/cat_test.go index c2d857973..ed1a7f162 100644 --- a/tests/go/cat_test.go +++ b/tests/go/cat_test.go @@ -49,7 +49,7 @@ func TestCat(t *testing.T) { pwd, err := os.Getwd() if err != nil { - t.Fatalf(err.Error()) + t.Fatalf(err) } for i := 0; i < 2; i++ { diff --git a/tests/go/solutions/cat/main.go b/tests/go/solutions/cat/main.go index bf1463e02..02d8a2291 100644 --- a/tests/go/solutions/cat/main.go +++ b/tests/go/solutions/cat/main.go @@ -1,10 +1,8 @@ package main import ( - "fmt" "io" "io/ioutil" - "log" "os" ) @@ -12,14 +10,13 @@ func main() { size := len(os.Args) if size == 1 { if _, err := io.Copy(os.Stdout, os.Stdin); err != nil { - log.Fatal(err) + panic(err) } } else { for i := 1; i < size; i++ { data, err := ioutil.ReadFile(os.Args[i]) if err != nil { - fmt.Println(err.Error()) - return + panic(err) } fmt.Print(string(data)) } diff --git a/tests/go/solutions/displayfile/main.go b/tests/go/solutions/displayfile/main.go index 616c9c104..4b33ae144 100644 --- a/tests/go/solutions/displayfile/main.go +++ b/tests/go/solutions/displayfile/main.go @@ -20,7 +20,7 @@ func main() { data, err := ioutil.ReadFile(fileName) if err != nil { - fmt.Println(err.Error()) + fmt.Println(err) return } diff --git a/tests/go/solutions/raid3/raid1aProg/raid1a.go b/tests/go/solutions/raid3/raid1aProg/raid1a.go index c7a6919a4..47ef74fab 100644 --- a/tests/go/solutions/raid3/raid1aProg/raid1a.go +++ b/tests/go/solutions/raid3/raid1aProg/raid1a.go @@ -14,7 +14,7 @@ func main() { secundArg, err2 := strconv.Atoi(os.Args[2]) if err != nil || err2 != nil { - fmt.Println(err.Error()) + fmt.Println(err) } solutions.Raid1a(firstArg, secundArg) } else { diff --git a/tests/go/solutions/raid3/raid1bProg/raid1b.go b/tests/go/solutions/raid3/raid1bProg/raid1b.go index 87979317a..0e7e2eaf0 100644 --- a/tests/go/solutions/raid3/raid1bProg/raid1b.go +++ b/tests/go/solutions/raid3/raid1bProg/raid1b.go @@ -14,7 +14,7 @@ func main() { secundArg, err2 := strconv.Atoi(os.Args[2]) if err != nil || err2 != nil { - fmt.Println(err.Error()) + fmt.Println(err) } solutions.Raid1b(firstArg, secundArg) } else { diff --git a/tests/go/solutions/raid3/raid1cProg/raid1c.go b/tests/go/solutions/raid3/raid1cProg/raid1c.go index 59ad18f28..5fc5ec3f4 100644 --- a/tests/go/solutions/raid3/raid1cProg/raid1c.go +++ b/tests/go/solutions/raid3/raid1cProg/raid1c.go @@ -14,7 +14,7 @@ func main() { secundArg, err2 := strconv.Atoi(os.Args[2]) if err != nil || err2 != nil { - fmt.Println(err.Error()) + fmt.Println(err) } solutions.Raid1c(firstArg, secundArg) } else { diff --git a/tests/go/solutions/raid3/raid1dProg/raid1d.go b/tests/go/solutions/raid3/raid1dProg/raid1d.go index 7daf0d682..2bc107692 100644 --- a/tests/go/solutions/raid3/raid1dProg/raid1d.go +++ b/tests/go/solutions/raid3/raid1dProg/raid1d.go @@ -14,7 +14,7 @@ func main() { secundArg, err2 := strconv.Atoi(os.Args[2]) if err != nil || err2 != nil { - fmt.Println(err.Error()) + fmt.Println(err) } solutions.Raid1d(firstArg, secundArg) } else { diff --git a/tests/go/solutions/raid3/raid1eProg/raid1e.go b/tests/go/solutions/raid3/raid1eProg/raid1e.go index c483a88c9..a53fefe7a 100644 --- a/tests/go/solutions/raid3/raid1eProg/raid1e.go +++ b/tests/go/solutions/raid3/raid1eProg/raid1e.go @@ -14,7 +14,7 @@ func main() { secundArg, err2 := strconv.Atoi(os.Args[2]) if err != nil || err2 != nil { - fmt.Println(err.Error()) + fmt.Println(err) } solutions.Raid1e(firstArg, secundArg) } else { diff --git a/tests/go/solutions/range/main.go b/tests/go/solutions/range/main.go index db390125b..6c948766c 100644 --- a/tests/go/solutions/range/main.go +++ b/tests/go/solutions/range/main.go @@ -14,7 +14,7 @@ func main() { secondArg, err = strconv.Atoi(os.Args[2]) } if err != nil { - fmt.Println(err.Error()) + fmt.Println(err) return } fmt.Println(rangeOf(firstArg, secondArg)) diff --git a/tests/go/solutions/reverserange/main.go b/tests/go/solutions/reverserange/main.go index 78e678754..a86af8c89 100644 --- a/tests/go/solutions/reverserange/main.go +++ b/tests/go/solutions/reverserange/main.go @@ -14,7 +14,7 @@ func main() { secondArg, err = strconv.Atoi(os.Args[2]) } if err != nil { - fmt.Println(err.Error()) + fmt.Println(err) return } fmt.Println(reverseRange(firstArg, secondArg)) diff --git a/tests/go/solutions/ztail/main.go b/tests/go/solutions/ztail/main.go index 0e4d2bdc4..9a830083a 100644 --- a/tests/go/solutions/ztail/main.go +++ b/tests/go/solutions/ztail/main.go @@ -42,7 +42,7 @@ func fileSize(fi *os.File) int64 { fil, err := fi.Stat() if err != nil { - fmt.Println(err.Error()) + fmt.Println(err) return 0 }