Closed drgolem closed 2 years ago
Added unit test TestDecodeTextParallel to demo an issue of decoding in multiple goroutines. run test:
go test -race ./...
result:
WARNING: DATA RACE Write at 0x00c0000aa0ee by goroutine 36: golang.org/x/text/encoding/unicode.(*utf16Decoder).Reset() /Users/val/goLand/pkg/mod/golang.org/x/text@v0.3.2/encoding/unicode/unicode.go:286 +0x57 golang.org/x/text/encoding.(*Decoder).Reset() <autogenerated>:1 +0x49 golang.org/x/text/transform.doAppend() /Users/val/goLand/pkg/mod/golang.org/x/text@v0.3.2/transform/transform.go:689 +0x90 golang.org/x/text/transform.Bytes() /Users/val/goLand/pkg/mod/golang.org/x/text@v0.3.2/transform/transform.go:674 +0x8f golang.org/x/text/encoding.(*Decoder).Bytes() /Users/val/goLand/pkg/mod/golang.org/x/text@v0.3.2/encoding/encoding.go:57 +0x30 github.com/bogem/id3v2/v2.decodeText()
this can be fixed by
//result, err := fromXEncoding.Decoder().Bytes(src) result, err := fromXEncoding.encoding.NewDecoder().Bytes(src)
This is just a proposal, please suggest better fix.
Added unit test TestDecodeTextParallel to demo an issue of decoding in multiple goroutines. run test:
result:
this can be fixed by
This is just a proposal, please suggest better fix.