Skip to content

Commit 7d78da6

Browse files
committed
add arg for show/ask
1 parent c10e928 commit 7d78da6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"log"
88
"math/rand"
99
"net/http"
10+
"os"
1011
"os/exec"
1112
"runtime"
1213
"time"
@@ -39,8 +40,10 @@ func openbrowser(url string) {
3940
}
4041

4142
func main() {
43+
arg := os.Args[1]
44+
4245
rand.Seed(time.Now().UnixNano())
43-
topStoriesUrl := "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
46+
topStoriesUrl := fmt.Sprintf("https://hacker-news.firebaseio.com/v0/%sstories.json?print=pretty", arg)
4447

4548
resp, err := http.Get(topStoriesUrl)
4649

@@ -54,7 +57,7 @@ func main() {
5457
if err != nil {
5558
panic(err)
5659
}
57-
60+
5861
var topStories []int64
5962
err = json.Unmarshal(body, &topStories)
6063
if err != nil {

0 commit comments

Comments
 (0)