Skip to content

Commit f71dfa8

Browse files
committed
ovsdb: unexport GoSet struct field
Signed-off-by: Dan Williams <[email protected]>
1 parent c915188 commit f71dfa8

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

ovsdb/bindings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func OvsToNative(column *ColumnSchema, ovsElem interface{}) (interface{}, error)
162162
} else if ovsSet.Len() == 0 {
163163
return reflect.Zero(naType).Interface(), nil
164164
}
165-
native, err := OvsToNativeAtomic(column.TypeObj.Key.Type, ovsSet.GoSet[0])
165+
native, err := OvsToNativeAtomic(column.TypeObj.Key.Type, ovsSet.goSet[0])
166166
if err != nil {
167167
return nil, err
168168
}

ovsdb/encoding_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func TestSet(t *testing.T) {
193193
var res OvsSet
194194
err = json.Unmarshal(jsonStr, &res)
195195
assert.Nil(t, err)
196-
assert.Equal(t, set.GoSet, res.GoSet, "they should have the same elements\n")
196+
assert.Equal(t, set.goSet, res.goSet, "they should have the same elements\n")
197197
})
198198
}
199199
}

ovsdb/set.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
// values in the set. All of the <atom>s must have the same type, and all
1616
// values must be unique within the set.
1717
type OvsSet struct {
18-
GoSet []interface{}
18+
goSet []interface{}
1919
maxSize int
2020
}
2121

@@ -51,7 +51,7 @@ func newOvsSetRaw(keyType string, maxSizePtr *int, obj interface{}) (OvsSet, err
5151
if v.Kind() == reflect.Invalid {
5252
// must be a nil pointer, so just return an empty set
5353
return OvsSet{
54-
GoSet: ovsSet,
54+
goSet: ovsSet,
5555
maxSize: maxSize,
5656
}, nil
5757
}
@@ -99,35 +99,35 @@ func newOvsSetRaw(keyType string, maxSizePtr *int, obj interface{}) (OvsSet, err
9999
return OvsSet{}, fmt.Errorf("ovsset supports only go slice/string/numbers/uuid or pointers to those types")
100100
}
101101
return OvsSet{
102-
GoSet: ovsSet,
102+
goSet: ovsSet,
103103
maxSize: maxSize,
104104
}, nil
105105
}
106106

107107
// MarshalJSON wil marshal an OVSDB style Set in to a JSON byte array
108108
func (o OvsSet) MarshalJSON() ([]byte, error) {
109-
switch l := len(o.GoSet); {
109+
switch l := len(o.goSet); {
110110
case l == 1:
111-
return json.Marshal(o.GoSet[0])
111+
return json.Marshal(o.goSet[0])
112112
case l > 0:
113113
var oSet []interface{}
114114
oSet = append(oSet, "set")
115-
oSet = append(oSet, o.GoSet)
115+
oSet = append(oSet, o.goSet)
116116
return json.Marshal(oSet)
117117
}
118118
return []byte("[\"set\",[]]"), nil
119119
}
120120

121121
// UnmarshalJSON will unmarshal a JSON byte array to an OVSDB style Set
122122
func (o *OvsSet) UnmarshalJSON(b []byte) (err error) {
123-
o.GoSet = make([]interface{}, 0)
123+
o.goSet = make([]interface{}, 0)
124124
if o.maxSize == 0 {
125125
o.maxSize = Unlimited
126126
}
127127
addToSet := func(o *OvsSet, v interface{}) error {
128128
goVal, err := ovsSliceToGoNotation(v)
129129
if err == nil {
130-
o.GoSet = append(o.GoSet, goVal)
130+
o.goSet = append(o.goSet, goVal)
131131
}
132132
return err
133133
}
@@ -166,41 +166,41 @@ func (o *OvsSet) UnmarshalJSON(b []byte) (err error) {
166166
}
167167

168168
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 {
170170
return fmt.Errorf("appending new value would exceed max set size %d", o.maxSize)
171171
}
172-
o.GoSet = append(o.GoSet, newVal...)
172+
o.goSet = append(o.goSet, newVal...)
173173
return nil
174174
}
175175

176176
func (o *OvsSet) Len() int {
177-
return len(o.GoSet)
177+
return len(o.goSet)
178178
}
179179

180180
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))
183183
}
184-
o.GoSet[idx] = newVal
184+
o.goSet[idx] = newVal
185185
return nil
186186
}
187187

188188
// HasElementType matches the given value's type with the set's element type.
189189
// It returns true if the set has at least one element, and that element is
190190
// of the given type, otherwise false.
191191
func (o *OvsSet) HasElementType(checkVal interface{}) bool {
192-
if len(o.GoSet) == 0 {
192+
if len(o.goSet) == 0 {
193193
return false
194194
}
195-
return reflect.ValueOf(checkVal).Type() == reflect.ValueOf(o.GoSet[0]).Type()
195+
return reflect.ValueOf(checkVal).Type() == reflect.ValueOf(o.goSet[0]).Type()
196196
}
197197

198198
// Range iterates over elements of the set and calls the given function for
199199
// each element. The function should return true if iteration should terminate,
200200
// a value to return to the caller of Range(), and/or an error (which also
201201
// terminates iteration).
202202
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 {
204204
done, err := elemFn(i, v)
205205
if err != nil {
206206
return err

ovsdb/updates2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (r *RowUpdate2) Merge(new *RowUpdate2) error {
8282
case OvsSet:
8383
oSet := currentRowData[k].(OvsSet)
8484
newSet := v.(OvsSet)
85-
if err := oSet.Append(newSet.GoSet...); err != nil {
85+
if err := oSet.Append(newSet.goSet...); err != nil {
8686
return err
8787
}
8888
// copy new appended set back to currentRowData

0 commit comments

Comments
 (0)