From 57537e98f4967124c0fb10451c533fd40007697a Mon Sep 17 00:00:00 2001 From: jake-shin0 Date: Thu, 25 Apr 2024 15:17:52 +0900 Subject: [PATCH] fix: invalid goroutine option --- autopprof_test.go | 7 +++++++ option.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/autopprof_test.go b/autopprof_test.go index a432a6d..371902b 100644 --- a/autopprof_test.go +++ b/autopprof_test.go @@ -57,6 +57,13 @@ func TestStart(t *testing.T) { }, want: ErrInvalidMemThreshold, }, + { + name: "invalid GoroutineThreshold value", + opt: Option{ + GoroutineThreshold: -1, + }, + want: ErrInvalidGoroutineThreshold, + }, { name: "when given reporter is nil", opt: Option{ diff --git a/option.go b/option.go index 8bf7c93..165b94c 100644 --- a/option.go +++ b/option.go @@ -62,7 +62,7 @@ func (o Option) validate() error { if o.MemThreshold < 0 || o.MemThreshold > 1 { return ErrInvalidMemThreshold } - if o.GoroutineThreshold <= 0 { + if o.GoroutineThreshold < 0 { return ErrInvalidGoroutineThreshold } if o.Reporter == nil {