Skip to content

Fix threadsafe.go threadSafeSet[T].UnmarshalJSON#157

Open
wangzhione wants to merge 1 commit intodeckarep:mainfrom
wangzhione:patch-3
Open

Fix threadsafe.go threadSafeSet[T].UnmarshalJSON#157
wangzhione wants to merge 1 commit intodeckarep:mainfrom
wangzhione:patch-3

Conversation

@wangzhione
Copy link

threadSafeSet[T].UnmarshalJSON Can modify threadUnsafeSet data, so need a write lock

threadSafeSet[T].UnmarshalJSON Can modify threadUnsafeSet data, so need a write lock
@wangzhione
Copy link
Author

A more appropriate approach

func (t *threadSafeSet[T]) UnmarshalJSON(b []byte) error {
	var i []T
	err := json.Unmarshal(b, &i)
	if err != nil {
		return err
	}

	t.Append(i...)
	return nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant