fix bug in encoder_test.go and make Generator.Next() a pointer receiver to advance ids

This commit is contained in:
Julian Daube 2016-09-24 16:19:20 +02:00
parent 70a21f8a11
commit c4135d2941
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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),
}