Bluelink: fix error if length of stamps is 0
This commit is contained in:
parent
451be5e357
commit
e1b19a3d87
1 changed files with 5 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package bluelink
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
|
@ -55,6 +56,10 @@ func (c *stampCollection) Get() (string, error) {
|
|||
position = int(time.Since(c.Generated).Milliseconds()) / c.Frequency
|
||||
}
|
||||
|
||||
if len(c.Stamps) == 0 {
|
||||
return "", errors.New("no stamps available")
|
||||
}
|
||||
|
||||
if position >= len(c.Stamps) {
|
||||
position = len(c.Stamps) - 1
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue