From 913f66cdc754e32b91a0c975770246d347dd1cfb Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Sun, 27 Jan 2019 17:45:23 +0700 Subject: [PATCH] small cleanup --- loader/loader.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/loader/loader.go b/loader/loader.go index a41f775..c2e09aa 100644 --- a/loader/loader.go +++ b/loader/loader.go @@ -44,27 +44,26 @@ func ImagesAsync(ctx context.Context, filePathOrUrls ...string) chan Result { func Image(ctx context.Context, filePathOrUrl string) Result { // Read - var imgReader io.Reader + var img io.Reader var fileName string - parsedUrl, isUrl := parseUrl(filePathOrUrl) - if isUrl { + if parsedUrl, ok := parseUrl(filePathOrUrl); ok { resp, err := getByUrl(ctx, filePathOrUrl) if err != nil { return Result{Err: err} } defer resp.Body.Close() - imgReader = resp.Body + img = resp.Body fileName = parsedUrl.Path - } else { + } else { // then it's file var err error - if imgReader, err = os.Open(filePathOrUrl); err != nil { + if img, err = os.Open(filePathOrUrl); err != nil { return Result{Err: err} } fileName = filePathOrUrl } - return decode(fileName, imgReader) + return decode(fileName, img) } func parseUrl(rawurl string) (*url.URL, bool) {