Files
bl/common/serialize/sturc/test_pack_init/pack_init_test.go
昔念 cc9f1fb45a refactor(info): 删除多余的信息结构体文件
- 移除了多个未使用的 Java 和 Go 信息结构体文件
- 优化了项目结构,减少了冗余代码
- 这些文件可能是早期开发阶段的遗留代码,现在已不再需要
2025-06-23 10:15:22 +08:00

30 lines
603 B
Go

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()
}