mapslice-json
mapslice-json copied to clipboard
fix DATA RACE when it calls nextIndex()
I found a DATA RACE error when I wrote some test code using mapslice-json.
You can reproduce quickly by invoking a test function included in this PR.
$ go test -race ./.... -run TestConcurrentUnmarshal
==================
WARNING: DATA RACE
Read at 0x0000007e6a28 by goroutine 10:
github.com/ake-persson/mapslice-json.nextIndex()
path/to/mapslice-json/mapslice.go:26 +0x127
github.com/ake-persson/mapslice-json.(*MapItem).UnmarshalJSON()
path/to/mapslice-json/mapslice.go:76 +0x113
encoding/json.(*decodeState).literalStore()
/usr/local/go1.22.0/src/encoding/json/decode.go:854 +0x394a
...
Also, I updated go version and MakeFile.