refactor: ifaces write an io reader

This commit is contained in:
Inanc Gumus
2019-11-11 15:29:32 +03:00
parent 327f1281d8
commit 2a57da47ac
3 changed files with 28 additions and 55 deletions

View File

@@ -16,6 +16,7 @@ import (
)
func main() {
// resp, err := http.Get("https://inancgumus.github.com/x/rosie.jpg")
resp, err := http.Get("https://inancgumus.github.com/x/rosie.unknown")
if err != nil {
fmt.Fprintln(os.Stderr, err)
@@ -30,8 +31,6 @@ func main() {
}
defer file.Close()
// io.Copy reads from pngReader first
// pngReader reads from the resp.Body
n, err := io.Copy(file, pngReader(resp.Body))
if err != nil {
fmt.Fprintln(os.Stderr, err)