From 30431c4fcca4885b3c5d1fc01396ba6e9db34d15 Mon Sep 17 00:00:00 2001 From: SimePel Date: Tue, 3 Apr 2018 20:13:46 +0700 Subject: [PATCH] Reduces nesting and inverts validURL condition --- main.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 7a5dfb0..066ceea 100644 --- a/main.go +++ b/main.go @@ -119,20 +119,18 @@ func main() { filename := flag.Arg(0) if filename == "" || filename == "-" { rawInput = os.Stdin + } else if validURL(filename) { + r, err := getURL(filename, insecureFlag) + if err != nil { + fatal(exitFetchURL, err) + } + rawInput = r } else { - if !validURL(filename) { - r, err := os.Open(filename) - if err != nil { - fatal(exitOpenFile, err) - } - rawInput = r - } else { - r, err := getURL(filename, insecureFlag) - if err != nil { - fatal(exitFetchURL, err) - } - rawInput = r + r, err := os.Open(filename) + if err != nil { + fatal(exitOpenFile, err) } + rawInput = r } var opts int