summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2022-04-17 20:29:04 -0600
committermo khan <mo@mokhan.ca>2022-04-17 20:29:04 -0600
commitb6e22122a55f3760646b0aee096f44514097ff22 (patch)
treee80a98be47d3731f3a51c72d7bc694dc639fa05f
parent83dcd54b70df5deeb151ee6b49fb3a75a3bac62c (diff)
print usage when a symbol is not given
-rw-r--r--main.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/main.go b/main.go
index e2102e5..5c03cf2 100644
--- a/main.go
+++ b/main.go
@@ -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)
}