Skip to content

Commit 1bddbd5

Browse files
Fixed the syntax.
1 parent e07f067 commit 1bddbd5

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

‎chapter9/listing01/listing01_test.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ func TestDownload(t *testing.T) {
2020
url, statusCode)
2121
{
2222
resp, err := http.Get(url)
23-
if err == nil {
24-
t.Log("\t\tShould be able to make the Get call.",
25-
succeed)
26-
} else {
23+
if err != nil {
2724
t.Fatal("\t\tShould be able to make the Get call.",
2825
failed, err)
2926
}
27+
t.Log("\t\tShould be able to make the Get call.",
28+
succeed)
3029

3130
defer resp.Body.Close()
3231

‎chapter9/listing02/listing02_test.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ func TestDownload(t *testing.T) {
2727
u.url, u.statusCode)
2828
{
2929
resp, err := http.Get(u.url)
30-
if err == nil {
31-
t.Log("\t\tShould be able to make the Get call.",
32-
succeed)
33-
} else {
30+
if err != nil {
3431
t.Fatal("\t\tShould be able to make the Get call.",
3532
failed, err)
3633
}
34+
t.Log("\t\tShould be able to make the Get call.",
35+
succeed)
3736

3837
defer resp.Body.Close()
3938

‎chapter9/listing03/listing03_test.go‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@ func TestDownload(t *testing.T) {
8282
server.URL, statusCode)
8383
{
8484
resp, err := http.Get(server.URL)
85-
if err == nil {
86-
t.Log("\t\tShould be able to make the Get call.",
87-
succeed)
88-
} else {
85+
if err != nil {
8986
t.Fatal("\t\tShould be able to make the Get call.",
9087
failed, err)
9188
}
89+
t.Log("\t\tShould be able to make the Get call.",
90+
succeed)
9291

9392
defer resp.Body.Close()
9493

0 commit comments

Comments
 (0)