on main help sign in
fix: small fixes in csync
commit70f899352fbe56fa4355732a4bebb1ec4fff0d60 authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateMon 28 Jul 2025, 15:48 (1 year ago) parentcdb311d
2 files changed+7−9
internal/csync/doc.go+3 internal/csync/slices_test.go+4−9
internal/csync/doc.gonew file+3
@@ -0,0 +1,3 @@
1+// Package csync provides concurrent data structures for safe access in
2+// multi-threaded environments.
3+package csync
internal/csync/slices_test.go+4−9
@@ -260,22 +260,17 @@ func TestSlice(t *testing.T) {
260260 var wg sync.WaitGroup
261261
262262 // Concurrent appends
263− for i := 0; i < numGoroutines; i++ {
264− wg.Add(1)
263+ for i := range numGoroutines {
264+ wg.Add(2)
265265 go func(start int) {
266266 defer wg.Done()
267− for j := 0; j < itemsPerGoroutine; j++ {
267+ for j := range itemsPerGoroutine {
268268 s.Append(start*itemsPerGoroutine + j)
269269 }
270270 }(i)
271− }
272−
273− // Concurrent reads
274− for i := 0; i < numGoroutines; i++ {
275− wg.Add(1)
276271 go func() {
277272 defer wg.Done()
278− for j := 0; j < itemsPerGoroutine; j++ {
273+ for range itemsPerGoroutine {
279274 s.Len() // Just read the length
280275 }
281276 }()