Skip to content

Commit ac3220c

Browse files
Added better indication of questions and answers
1 parent 3a71e16 commit ac3220c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

goso.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ type Config struct {
257257
Client *http.Client
258258
}
259259
type Answer struct {
260+
Title string
260261
Author string
261262
Score int
262263
Body string
@@ -275,14 +276,16 @@ func (a *Answer) String() string {
275276
}
276277
return fmt.Sprintf(`
277278
%s
278-
%s[%d]%s %sAnswer from %s%s%s
279+
%s[%d]%s %s[Answer] %s%s
280+
%sAuthor: %s%s
279281
%sDate: %s%s
280282
%sLink: %s%s
281283
%s
282284
283285
`,
284286
line,
285-
color, a.Score, reset, answerColor, bold, a.Author, reset,
287+
color, a.Score, reset, answerColor, a.Title, reset,
288+
lightgray, a.Author, reset,
286289
lightgray, a.Date.Format(time.RFC822), reset,
287290
lightgray, a.Link, reset,
288291
line)
@@ -306,7 +309,7 @@ func (r *Result) String() string {
306309

307310
return fmt.Sprintf(`
308311
%s
309-
%s[%d]%s %s%s%s%s
312+
%s[%d]%s %s%s[Question] %s%s
310313
%sDate: %s%s
311314
%sLink: %s%s
312315
%s`,
@@ -440,6 +443,7 @@ func FetchStackOverflow(conf *Config, results map[int]*Result) error {
440443
}
441444
result.Answers = append(result.Answers,
442445
&Answer{
446+
Title: result.Title,
443447
Author: item.Owner.DisplayName,
444448
Score: item.Score,
445449
Body: item.Body,

goso_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func fetchStackOverflow(conf *Config, results map[int]*Result) error {
8383
}
8484
result.Answers = append(result.Answers,
8585
&Answer{
86+
Title: result.Title,
8687
Author: item.Owner.DisplayName,
8788
Score: item.Score,
8889
Body: item.Body,

0 commit comments

Comments
 (0)