Set static vars outside of init
This commit is contained in:
parent
e0866c8470
commit
85fa5997dd
12
hn.go
12
hn.go
|
@ -22,16 +22,10 @@ type Story struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
HackerNewsUrl string
|
HackerNewsUrl = "https://news.ycombinator.com"
|
||||||
HackerNewsFirebaseUrl string
|
|
||||||
HackerNewsLinkRegexp *regexp.Regexp
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
HackerNewsUrl = "https://news.ycombinator.com"
|
|
||||||
HackerNewsFirebaseUrl = "https://hacker-news.firebaseio.com/v0"
|
HackerNewsFirebaseUrl = "https://hacker-news.firebaseio.com/v0"
|
||||||
HackerNewsLinkRegexp = regexp.MustCompile(`(?:https?:\/\/)?news\.ycombinator\.com\/item\?id=([0-9]+)`)
|
HackerNewsLinkRegexp = regexp.MustCompile(`(?:https?:\/\/)?news\.ycombinator\.com\/item\?id=([0-9]+)`)
|
||||||
}
|
)
|
||||||
|
|
||||||
func FetchHackerNewsTopStories() []Story {
|
func FetchHackerNewsTopStories() []Story {
|
||||||
// API docs: https://github.com/HackerNews/API
|
// API docs: https://github.com/HackerNews/API
|
||||||
|
|
6
sn.go
6
sn.go
|
@ -80,14 +80,12 @@ type ItemsResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
StackerNewsUrl string
|
StackerNewsUrl = "https://stacker.news"
|
||||||
SnApiUrl string
|
SnApiUrl = "https://stacker.news/api/graphql"
|
||||||
SnAuthCookie string
|
SnAuthCookie string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
StackerNewsUrl = "https://stacker.news"
|
|
||||||
SnApiUrl = "https://stacker.news/api/graphql"
|
|
||||||
err := godotenv.Load()
|
err := godotenv.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error loading .env file")
|
log.Fatal("Error loading .env file")
|
||||||
|
|
Loading…
Reference in New Issue