@@ -15,7 +15,7 @@ import (
15
15
// values in the set. All of the <atom>s must have the same type, and all
16
16
// values must be unique within the set.
17
17
type OvsSet struct {
18
- GoSet []interface {}
18
+ goSet []interface {}
19
19
maxSize int
20
20
}
21
21
@@ -51,7 +51,7 @@ func newOvsSetRaw(keyType string, maxSizePtr *int, obj interface{}) (OvsSet, err
51
51
if v .Kind () == reflect .Invalid {
52
52
// must be a nil pointer, so just return an empty set
53
53
return OvsSet {
54
- GoSet : ovsSet ,
54
+ goSet : ovsSet ,
55
55
maxSize : maxSize ,
56
56
}, nil
57
57
}
@@ -99,35 +99,35 @@ func newOvsSetRaw(keyType string, maxSizePtr *int, obj interface{}) (OvsSet, err
99
99
return OvsSet {}, fmt .Errorf ("ovsset supports only go slice/string/numbers/uuid or pointers to those types" )
100
100
}
101
101
return OvsSet {
102
- GoSet : ovsSet ,
102
+ goSet : ovsSet ,
103
103
maxSize : maxSize ,
104
104
}, nil
105
105
}
106
106
107
107
// MarshalJSON wil marshal an OVSDB style Set in to a JSON byte array
108
108
func (o OvsSet ) MarshalJSON () ([]byte , error ) {
109
- switch l := len (o .GoSet ); {
109
+ switch l := len (o .goSet ); {
110
110
case l == 1 :
111
- return json .Marshal (o .GoSet [0 ])
111
+ return json .Marshal (o .goSet [0 ])
112
112
case l > 0 :
113
113
var oSet []interface {}
114
114
oSet = append (oSet , "set" )
115
- oSet = append (oSet , o .GoSet )
115
+ oSet = append (oSet , o .goSet )
116
116
return json .Marshal (oSet )
117
117
}
118
118
return []byte ("[\" set\" ,[]]" ), nil
119
119
}
120
120
121
121
// UnmarshalJSON will unmarshal a JSON byte array to an OVSDB style Set
122
122
func (o * OvsSet ) UnmarshalJSON (b []byte ) (err error ) {
123
- o .GoSet = make ([]interface {}, 0 )
123
+ o .goSet = make ([]interface {}, 0 )
124
124
if o .maxSize == 0 {
125
125
o .maxSize = Unlimited
126
126
}
127
127
addToSet := func (o * OvsSet , v interface {}) error {
128
128
goVal , err := ovsSliceToGoNotation (v )
129
129
if err == nil {
130
- o .GoSet = append (o .GoSet , goVal )
130
+ o .goSet = append (o .goSet , goVal )
131
131
}
132
132
return err
133
133
}
@@ -166,41 +166,41 @@ func (o *OvsSet) UnmarshalJSON(b []byte) (err error) {
166
166
}
167
167
168
168
func (o * OvsSet ) Append (newVal ... interface {}) error {
169
- if o .maxSize > 0 && len (o .GoSet )+ len (newVal ) > o .maxSize {
169
+ if o .maxSize > 0 && len (o .goSet )+ len (newVal ) > o .maxSize {
170
170
return fmt .Errorf ("appending new value would exceed max set size %d" , o .maxSize )
171
171
}
172
- o .GoSet = append (o .GoSet , newVal ... )
172
+ o .goSet = append (o .goSet , newVal ... )
173
173
return nil
174
174
}
175
175
176
176
func (o * OvsSet ) Len () int {
177
- return len (o .GoSet )
177
+ return len (o .goSet )
178
178
}
179
179
180
180
func (o * OvsSet ) Replace (idx int , newVal interface {}) error {
181
- if idx > len (o .GoSet )- 1 {
182
- return fmt .Errorf ("attempted to access element %d beyond end of array (length %d)" , idx , len (o .GoSet ))
181
+ if idx > len (o .goSet )- 1 {
182
+ return fmt .Errorf ("attempted to access element %d beyond end of array (length %d)" , idx , len (o .goSet ))
183
183
}
184
- o .GoSet [idx ] = newVal
184
+ o .goSet [idx ] = newVal
185
185
return nil
186
186
}
187
187
188
188
// HasElementType matches the given value's type with the set's element type.
189
189
// It returns true if the set has at least one element, and that element is
190
190
// of the given type, otherwise false.
191
191
func (o * OvsSet ) HasElementType (checkVal interface {}) bool {
192
- if len (o .GoSet ) == 0 {
192
+ if len (o .goSet ) == 0 {
193
193
return false
194
194
}
195
- return reflect .ValueOf (checkVal ).Type () == reflect .ValueOf (o .GoSet [0 ]).Type ()
195
+ return reflect .ValueOf (checkVal ).Type () == reflect .ValueOf (o .goSet [0 ]).Type ()
196
196
}
197
197
198
198
// Range iterates over elements of the set and calls the given function for
199
199
// each element. The function should return true if iteration should terminate,
200
200
// a value to return to the caller of Range(), and/or an error (which also
201
201
// terminates iteration).
202
202
func (o * OvsSet ) Range (elemFn func (int , interface {}) (bool , error )) error {
203
- for i , v := range o .GoSet {
203
+ for i , v := range o .goSet {
204
204
done , err := elemFn (i , v )
205
205
if err != nil {
206
206
return err
0 commit comments