Skip to content

Commit

Permalink
Handle errors in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur White committed Jul 23, 2017
1 parent b3f85cd commit 6a6115a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ Use [Get](https://godoc.org/github.com/gowww/client#Get), [Post](https://godoc.o
Options are chainable:

```Go
file, _ := os.Open("data/one.txt")
file, err := os.Open("data/one.txt")
if err != nil {
panic(err)
}
defer file.Close()

req := client.Post("http://example.com").
Expand Down
10 changes: 8 additions & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (
)

func Example() {
file, _ := os.Open("data/one.txt")
file, err := os.Open("data/one.txt")
if err != nil {
panic(err)
}
defer file.Close()

req := client.Post("http://example.com").
Expand All @@ -24,7 +27,10 @@ func Example() {
OpenFile("picture", "one.png").
OpenFile("picture", "two.png")

res, _ := req.Do()
res, err := req.Do()
if err != nil {
panic(err)
}
defer res.Close()

fmt.Println(res)
Expand Down

0 comments on commit 6a6115a

Please sign in to comment.