v0.0.227 error on duplicate exerr.ErrorType

This commit is contained in:
2023-08-08 15:28:29 +02:00
parent 4a3f25baa0
commit 376c6cab50
3 changed files with 26 additions and 15 deletions

View File

@@ -7,6 +7,9 @@ type SyncSet[TData comparable] struct {
lock sync.Mutex
}
// Add adds `value` to the set
// returns true if the value was actually inserted
// returns false if the value already existed
func (s *SyncSet[TData]) Add(value TData) bool {
s.lock.Lock()
defer s.lock.Unlock()
@@ -15,10 +18,10 @@ func (s *SyncSet[TData]) Add(value TData) bool {
s.data = make(map[TData]bool)
}
_, ok := s.data[value]
_, existsInPreState := s.data[value]
s.data[value] = true
return !ok
return !existsInPreState
}
func (s *SyncSet[TData]) AddAll(values []TData) {