@@ -12,9 +12,6 @@ var ErrCollision = errors.New("key already exists")
1212// Returned when a requested item does not exist in the set.
1313var ErrMissing = errors .New ("item does not exist" )
1414
15- // Returned when a nil item is added. Nil values are considered expired and invalid.
16- var ErrNil = errors .New ("item value must not be nil" )
17-
1815// ZeroValue can be used when we only care about the key, not about the value.
1916var ZeroValue = struct {}{}
2017
@@ -100,17 +97,14 @@ func (s *Set) Get(key string) (Item, error) {
10097func (s * Set ) cleanup (key string ) {
10198 s .Lock ()
10299 item , ok := s .lookup [key ]
103- if ok && item == nil {
100+ if ok && item . Value () == nil {
104101 delete (s .lookup , key )
105102 }
106103 s .Unlock ()
107104}
108105
109106// Add item to this set if it does not exist already.
110107func (s * Set ) Add (item Item ) error {
111- if item .Value () == nil {
112- return ErrNil
113- }
114108 key := s .normalize (item .Key ())
115109
116110 s .Lock ()
@@ -127,9 +121,6 @@ func (s *Set) Add(item Item) error {
127121
128122// Set item to this set, even if it already exists.
129123func (s * Set ) Set (item Item ) error {
130- if item .Value () == nil {
131- return ErrNil
132- }
133124 key := s .normalize (item .Key ())
134125
135126 s .Lock ()
@@ -156,9 +147,6 @@ func (s *Set) Remove(key string) error {
156147// Replace oldKey with a new item, which might be a new key.
157148// Can be used to rename items.
158149func (s * Set ) Replace (oldKey string , item Item ) error {
159- if item .Value () == nil {
160- return ErrNil
161- }
162150 newKey := s .normalize (item .Key ())
163151 oldKey = s .normalize (oldKey )
164152
0 commit comments