fix bug in encoder_test.go and make Generator.Next() a pointer receiver to advance ids
This commit is contained in:
parent
70a21f8a11
commit
c4135d2941
@ -3,7 +3,7 @@ package ID_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"go.dedaa.de/julixau/inftut/ID"
|
||||
"go.dedaa.de/julixau/ID"
|
||||
)
|
||||
|
||||
// Verify that the Encoder works
|
||||
|
@ -12,13 +12,13 @@ type Generator struct {
|
||||
Last Type
|
||||
}
|
||||
|
||||
func (idg Generator) Next() Type {
|
||||
func (idg *Generator) Next() Type {
|
||||
idg.Last = (idg.Last + idg.step) % MaxID
|
||||
return idg.Last
|
||||
}
|
||||
|
||||
func New(seed uint32) Generator {
|
||||
return Generator{
|
||||
func New(seed uint32) *Generator {
|
||||
return &Generator{
|
||||
Last: Type(seed % MaxID),
|
||||
step: Type((rand.Uint32() % MaxID) | 1),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user