From a373bf8eda00a33fa2fefb00be8f901a626472b9 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Tue, 7 Mar 2023 15:36:20 -0700 Subject: [PATCH] system: fix sink pool test --- system/sink_pool_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/system/sink_pool_test.go b/system/sink_pool_test.go index 1f5ea70..7d0fa09 100644 --- a/system/sink_pool_test.go +++ b/system/sink_pool_test.go @@ -15,7 +15,16 @@ func MutexLocked(m *sync.RWMutex) bool { state := v.FieldByName("w").FieldByName("state") - return state.Int()&1 == 1 || v.FieldByName("readerCount").Int() > 0 + readerCountField := v.FieldByName("readerCount") + // go1.20 changed readerCount to an atomic + // ref; https://github.com/golang/go/commit/e509452727b469d89a3fc4a7d1cbf9d3f110efee + var readerCount int64 + if readerCountField.Kind() == reflect.Struct { + readerCount = readerCountField.FieldByName("v").Int() + } else { + readerCount = readerCountField.Int() + } + return state.Int()&1 == 1 || readerCount > 0 } func TestSink(t *testing.T) {