Skip to content

Commit

Permalink
Reduces nesting and inverts validURL condition
Browse files Browse the repository at this point in the history
  • Loading branch information
SimePel committed Apr 3, 2018
1 parent 68db814 commit 30431c4
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 30431c4

Please sign in to comment.