diff --git a/checkers/testdata/wrapperFunc/negative_tests.go b/checkers/testdata/wrapperFunc/negative_tests.go index 314d3265b..7aa3b7e63 100644 --- a/checkers/testdata/wrapperFunc/negative_tests.go +++ b/checkers/testdata/wrapperFunc/negative_tests.go @@ -10,6 +10,11 @@ import ( func appliedSuggestions(s string, b []byte) { var wg sync.WaitGroup wg.Done() + wg.Add(1) + + var buf bytes.Buffer + buf.Reset() + buf.Truncate(1) strings.ToTitle(s) strings.ReplaceAll(s, "a", "b") diff --git a/checkers/testdata/wrapperFunc/positive_tests.go b/checkers/testdata/wrapperFunc/positive_tests.go index c6547e02a..8c69fa527 100644 --- a/checkers/testdata/wrapperFunc/positive_tests.go +++ b/checkers/testdata/wrapperFunc/positive_tests.go @@ -13,6 +13,10 @@ func f(s string, b []byte) { /*! use WaitGroup.Done method in `wg.Add(-1)` */ wg.Add(-1) + var buf bytes.Buffer + /*! use Buffer.Reset method in `buf.Truncate(0)` */ + buf.Truncate(0) + /*! use strings.ToTitle method in `strings.Map(unicode.ToTitle, s)` */ strings.Map(unicode.ToTitle, s) diff --git a/checkers/wrapperFunc_checker.go b/checkers/wrapperFunc_checker.go index e2308ff4b..43c5aaa29 100644 --- a/checkers/wrapperFunc_checker.go +++ b/checkers/wrapperFunc_checker.go @@ -39,6 +39,10 @@ func init() { "sync.WaitGroup.Add => WaitGroup.Done": { {0, "-1"}, }, + + "bytes.Buffer.Truncate => Buffer.Reset": { + {0, "0"}, + }, } pkgPatterns := map[string][]arg{