diff --git a/atr/atrib.go b/atr/atrib.go index 963bd2d..b224dc4 100644 --- a/atr/atrib.go +++ b/atr/atrib.go @@ -1,21 +1,25 @@ package atr +import "strings" + type Atr string +const sep Atr = "," + // New Atr func New(a string) Atr { return Atr(a) } //Glue slice Atr to Atr -func Glue(atr []Atr) Atr { +func Glue(atr ...Atr) Atr { var endatr Atr lenatr := len(atr) for _, a0 := range atr { if a0 != "" { endatr = endatr + a0 if lenatr > 1 { - endatr = endatr + "," + endatr = endatr + sep } } lenatr-- @@ -23,3 +27,13 @@ func Glue(atr []Atr) Atr { return endatr } + +//Split Atr to slice Atr +func Split(a Atr) []Atr { + var endatr []Atr + split := strings.Split(string(a), string(sep)) + for _, s := range split { + endatr = append(endatr, Atr(s)) + } + return endatr +}