"refactor(common): 重构序列化工具包,将serialize重命名为utils并添加bitset组件"

This commit is contained in:
1
2025-07-25 01:29:03 +00:00
parent 84d6d99356
commit 58e972eea3
113 changed files with 11 additions and 11 deletions

View File

@@ -0,0 +1,29 @@
package test_pack_init
import (
"bytes"
"github.com/lunixbochs/struc"
"sync"
"testing"
)
type Example struct {
I int `struc:int`
}
// TestParallelPack checks whether Pack is goroutine-safe. Run it with -race flag.
// Keep it as a single test in package since it is likely to be triggered on initialization
// of global objects reported as a data race by race detector.
func TestParallelPack(t *testing.T) {
var wg sync.WaitGroup
val := Example{}
for i := 0; i < 2; i++ {
wg.Add(1)
go func() {
defer wg.Done()
var buf bytes.Buffer
_ = struc.Pack(&buf, &val)
}()
}
wg.Wait()
}