add stringer

This commit is contained in:
Balakrishnan Balasubramanian 2022-06-26 23:37:08 -04:00
parent ded32cd3e6
commit c8af4d4f84
3 changed files with 28 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"time" "time"
) )
//go:generate stringer -type=Step
type Step int type Step int
const ( const (

View File

@ -3,6 +3,7 @@ package pubsub
import ( import (
"sync" "sync"
"testing" "testing"
"time"
) )
func TestDupePublisher(t *testing.T) { func TestDupePublisher(t *testing.T) {
@ -67,6 +68,7 @@ func TestPubSub(t *testing.T) {
}() }()
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
pc <- "blah" pc <- "blah"
time.Sleep(166 * time.Millisecond)
if i == 5 { if i == 5 {
// time.Sleep(100 * time.Millisecond) // time.Sleep(100 * time.Millisecond)
//time.Sleep(1 * time.Second) //time.Sleep(1 * time.Second)

25
pubsub/step_string.go Normal file
View File

@ -0,0 +1,25 @@
// Code generated by "stringer -type=Step"; DO NOT EDIT.
package pubsub
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[NotStarted-0]
_ = x[Publishing-1]
_ = x[Done-2]
}
const _Step_name = "NotStartedPublishingDone"
var _Step_index = [...]uint8{0, 10, 20, 24}
func (i Step) String() string {
if i < 0 || i >= Step(len(_Step_index)-1) {
return "Step(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Step_name[_Step_index[i]:_Step_index[i+1]]
}