forked from jzelinskie/geddit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subreddit.go
36 lines (32 loc) · 989 Bytes
/
subreddit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2012 Jimmy Zelinskie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package geddit
import (
"fmt"
)
// Subreddit represents a subreddit from reddit.com.
type Subreddit struct {
Name string `json:"display_name"`
Title string `json:"title"`
Desc string `json:"description"`
PublicDesc string `json:"public_description"`
URL string `json:"url"`
FullID string `json:"name"`
ID string `json:"id"`
HeaderImg string `json:"header_img"`
DateCreated float64 `json:"created_utc"`
NumSubs int `json:"subscribers"`
IsNSFW bool `json:"over18"`
}
// String returns the string representation of a subreddit.
func (s *Subreddit) String() string {
var subs string
switch s.NumSubs {
case 1:
subs = "1 subscriber"
default:
subs = fmt.Sprintf("%d subscribers", s.NumSubs)
}
return fmt.Sprintf("%s (%s)", s.Title, subs)
}