diff options
| author | mo khan <mo@mokhan.ca> | 2022-04-17 20:29:04 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2022-04-17 20:29:04 -0600 |
| commit | b6e22122a55f3760646b0aee096f44514097ff22 (patch) | |
| tree | e80a98be47d3731f3a51c72d7bc694dc639fa05f | |
| parent | 83dcd54b70df5deeb151ee6b49fb3a75a3bac62c (diff) | |
print usage when a symbol is not given
| -rw-r--r-- | main.go | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -31,14 +31,11 @@ func Visit(n *html.Node) { } func main() { - response, err1 := http.Get("https://finance.yahoo.com/quote/MSFT/") - if err1 != nil { - os.Exit(1) - } - - doc, err := html.Parse(response.Body) - if err != nil { - os.Exit(2) + if len(os.Args) != 2 { + fmt.Printf("Usage:\n\t%s <symbol>\n", os.Args[0]) + return } + response, _ := http.Get(fmt.Sprintf("https://finance.yahoo.com/quote/%s/", os.Args[1])) + doc, _ := html.Parse(response.Body) Visit(doc) } |
