Skip to content

Commit fc09bdb

Browse files
committed
refactor: Rename local variables
Standarize variable names in searching functions.
1 parent 60b50f9 commit fc09bdb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

hackernews.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ func SearchHackerNews(ctx context.Context, client http.Client, query string) ([]
3333
searchURL := "http://hn.algolia.com/api/v1/search?tags=story&query="
3434
discussions := make([]Discussion, 0)
3535

36-
raw, err := client.Get(ctx, searchURL+url.QueryEscape(query))
36+
r, err := client.Get(ctx, searchURL+url.QueryEscape(query))
3737
if err != nil {
3838
return discussions, err
3939
}
40-
defer raw.Body.Close()
40+
defer r.Body.Close()
4141

42-
body, err := io.ReadAll(raw.Body)
42+
body, err := io.ReadAll(r.Body)
4343
if err != nil {
4444
return discussions, err
4545
}

lobsters.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ func SearchLobsters(ctx context.Context, client http.Client, query string) ([]Di
2121
query = "domain:" + query
2222
}
2323

24-
raw, err := client.Get(ctx, searchURL+url.QueryEscape(query))
24+
r, err := client.Get(ctx, searchURL+url.QueryEscape(query))
2525
if err != nil {
2626
return discussions, err
2727
}
28-
defer raw.Body.Close()
28+
defer r.Body.Close()
2929

30-
doc, err := html.Parse(raw.Body)
30+
body, err := html.Parse(r.Body)
3131
if err != nil {
3232
return discussions, err
3333
}
3434

35-
for _, d := range html.FindAll(doc, "ol > li") {
36-
srcNode := html.First(d, ".link > a")
37-
commentNode := html.First(d, ".mobile_comments")
35+
for _, listItem := range html.FindAll(body, "ol > li") {
36+
srcNode := html.First(listItem, ".link > a")
37+
commentNode := html.First(listItem, ".mobile_comments")
3838
comments, err := strconv.Atoi(html.Text(html.First(commentNode, "span")))
3939
if err != nil {
4040
comments = 0

0 commit comments

Comments
 (0)