Skip to content

Commit

Permalink
attempt GolangUnited#2. fix for Time zero value
Browse files Browse the repository at this point in the history
  • Loading branch information
dlapanik committed May 25, 2022
1 parent f812d57 commit 2accda9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (c *Cache) Get(key string) (string, bool) {
return "", false
}

if value.deadline.Before(time.Now()) {
if !value.deadline.IsZero() && value.deadline.Before(time.Now()) {
delete(c.data, key)
return "", false
}
Expand All @@ -42,7 +42,7 @@ func (c *Cache) Keys() []string {
now := time.Now()

for key, value := range c.data {
if value.deadline.Before(now) {
if !value.deadline.IsZero() && value.deadline.Before(now) {
delete(c.data, key)
} else {
keys = append(keys, key)
Expand Down

0 comments on commit 2accda9

Please sign in to comment.