Skip to content

Commit

Permalink
Merge pull request #90 from tdakkota/fix-gomap
Browse files Browse the repository at this point in the history
Fix gomap datarace
  • Loading branch information
philippgille committed Feb 10, 2020
2 parents 1f76ccc + 4e79f38 commit d421395
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gomap/gomap.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func (s Store) Delete(k string) error {
return err
}

s.lock.Lock()
defer s.lock.Unlock()
delete(s.m, k)
return nil
}
Expand Down
10 changes: 10 additions & 0 deletions test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,14 @@ func InteractWithStore(store gokv.Store, key string, t *testing.T, waitGroup *sy
if err != nil {
t.Error(err)
}
// Delete
err = store.Delete(key)
if err != nil {
t.Error(err)
}
// Read
_, err = store.Get(key, new(Foo))
if err != nil {
t.Error(err)
}
}

0 comments on commit d421395

Please sign in to comment.