mirror of
https://github.com/idanoo/NZCovidBot
synced 2025-07-02 11:42:15 +00:00
Use reference for lastUpdatedTime
This commit is contained in:
parent
e1bb1a1ebe
commit
1b9339c371
2 changed files with 10 additions and 9 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
// Time of last succesful poll
|
||||
var lastUpdated time.Time
|
||||
var lastUpdated *time.Time
|
||||
|
||||
// Main func
|
||||
func Lesgoooo() {
|
||||
|
@ -40,7 +40,7 @@ func Lesgoooo() {
|
|||
}
|
||||
|
||||
// getLastPollTime - If run previously, get last TS, otherwise Now()
|
||||
func getLastPollTime() time.Time {
|
||||
func getLastPollTime() *time.Time {
|
||||
// Set default of *now* if never run so we don't spam everything
|
||||
lastPoll := time.Now()
|
||||
|
||||
|
@ -50,19 +50,19 @@ func getLastPollTime() time.Time {
|
|||
b, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
log.Printf("Unable to read lastUpdated.txt: %s", err)
|
||||
return lastPoll
|
||||
return &lastPoll
|
||||
}
|
||||
|
||||
i, err := strconv.ParseInt(string(b), 10, 64)
|
||||
if err != nil {
|
||||
log.Printf("Unable to read lastUpdated.txt: %s", err)
|
||||
return lastPoll
|
||||
return &lastPoll
|
||||
}
|
||||
|
||||
lastPoll = time.Unix(i, 0)
|
||||
}
|
||||
|
||||
return lastPoll
|
||||
return &lastPoll
|
||||
}
|
||||
|
||||
func postTheUpdates() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue