From 5bf0c10525f98b161a6c0156519e934f7a21e39f Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Wed, 26 Oct 2022 13:43:51 +0200 Subject: [PATCH] Randomness apparently not good enough for windows. Tests were failing. This fix improves it --- msg.go | 4 ++-- msg_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/msg.go b/msg.go index 5ef84eb..0e1aca3 100644 --- a/msg.go +++ b/msg.go @@ -360,9 +360,9 @@ func (m *Msg) SetMessageID() { ct := time.Now().UnixNano() r := rand.New(rand.NewSource(ct)) rn := r.Int63() - pid := os.Getpid() + pid := os.Getpid() * (r.Intn(10000) + 1) cts := fmt.Sprintf("%d", ct) - mid := fmt.Sprintf("%d.%d.%s@%s", pid, rn, cts[:15], hn) + mid := fmt.Sprintf("%d.%d.%s@%s", pid, rn, cts[:16], hn) m.SetMessageIDWithValue(mid) } diff --git a/msg_test.go b/msg_test.go index 2f27e39..dc55eca 100644 --- a/msg_test.go +++ b/msg_test.go @@ -710,7 +710,7 @@ func TestMsg_SetMessageIDRandomness(t *testing.T) { } for k, v := range c { if v > 1 { - t.Errorf("MessageID randomness not give. MessageID %q was generated %d times", k, v) + t.Errorf("MessageID randomness not given. MessageID %q was generated %d times", k, v) } } }