s0rg/crawley

View on GitHub
internal/values/list.go

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
package values

import "strings"

type List struct {
    Values []string
}

func (s *List) Set(val string) (err error) {
    switch {
    case strings.ContainsRune(val, ','):
        s.Values = append(s.Values, strings.Split(val, ",")...)
    default:
        s.Values = append(s.Values, val)
    }

    return
}

func (s *List) String() (rv string) {
    return strings.Join(s.Values, ",")
}