From 12143f12961abe523c94a6a926d20e2b1097b232 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Tue, 25 Apr 2023 02:25:59 +0200 Subject: [PATCH] Replace ItemID with int --- hn.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hn.go b/hn.go index 4039f1e..2259b01 100644 --- a/hn.go +++ b/hn.go @@ -10,14 +10,12 @@ import ( "strconv" ) -type ItemID = int - type Story struct { - ID ItemID + ID int By string // username of author Time int // UNIX timestamp Descendants int // number of comments - Kids []ItemID + Kids []int Score int Title string Url string @@ -66,7 +64,7 @@ func FetchHackerNewsTopStories() []Story { return stories[:] } -func FetchStoryById(id ItemID) Story { +func FetchStoryById(id int) Story { url := fmt.Sprintf("https://hacker-news.firebaseio.com/v0/item/%d.json", id) resp, err := http.Get(url) if err != nil { @@ -84,7 +82,7 @@ func FetchStoryById(id ItemID) Story { return story } -func ParseHackerNewsLink(link string) (ItemID, error) { +func ParseHackerNewsLink(link string) (int, error) { match := HackerNewsLinkRegexp.FindStringSubmatch(link) if len(match) == 0 { return -1, errors.New("input is not a hacker news link")