From c8af4d4f848b3579f94e49704ce074324bc5d816 Mon Sep 17 00:00:00 2001 From: balki <3070606-balki@users.noreply.gitlab.com> Date: Sun, 26 Jun 2022 23:37:08 -0400 Subject: [PATCH] add stringer --- pubsub/pt.go | 1 + pubsub/pt_test.go | 2 ++ pubsub/step_string.go | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 pubsub/step_string.go diff --git a/pubsub/pt.go b/pubsub/pt.go index c226647..3861cab 100644 --- a/pubsub/pt.go +++ b/pubsub/pt.go @@ -6,6 +6,7 @@ import ( "time" ) +//go:generate stringer -type=Step type Step int const ( diff --git a/pubsub/pt_test.go b/pubsub/pt_test.go index 8a26cc2..fdd20bc 100644 --- a/pubsub/pt_test.go +++ b/pubsub/pt_test.go @@ -3,6 +3,7 @@ package pubsub import ( "sync" "testing" + "time" ) func TestDupePublisher(t *testing.T) { @@ -67,6 +68,7 @@ func TestPubSub(t *testing.T) { }() for i := 0; i < 10; i++ { pc <- "blah" + time.Sleep(166 * time.Millisecond) if i == 5 { // time.Sleep(100 * time.Millisecond) //time.Sleep(1 * time.Second) diff --git a/pubsub/step_string.go b/pubsub/step_string.go new file mode 100644 index 0000000..5c88be1 --- /dev/null +++ b/pubsub/step_string.go @@ -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]] +}