diff --git a/common/collect/string_list.go b/common/collect/string_list.go index 498f50eca..528c213e9 100644 --- a/common/collect/string_list.go +++ b/common/collect/string_list.go @@ -7,6 +7,6 @@ func NewStringList(raw []string) *StringList { return &list } -func (this *StringList) Len() int { - return len(*this) +func (this StringList) Len() int { + return len(this) } diff --git a/common/collect/string_list_json_test.go b/common/collect/string_list_json_test.go index beb3d0690..ca2fdc119 100644 --- a/common/collect/string_list_json_test.go +++ b/common/collect/string_list_json_test.go @@ -18,3 +18,13 @@ func TestStringListUnmarshalError(t *testing.T) { err := json.Unmarshal([]byte(rawJson), list) assert.Error(err).IsNotNil() } + +func TestStringListLen(t *testing.T) { + assert := assert.On(t) + + rawJson := `"a, b, c, d"` + list := new(StringList) + err := json.Unmarshal([]byte(rawJson), list) + assert.Error(err).IsNil() + assert.Int(list.Len()).Equals(4) +}