From 758979f11b689e3cb5216fd7f2635d29344d0de2 Mon Sep 17 00:00:00 2001 From: Anatoly Prohacky Date: Sat, 13 Aug 2022 16:50:20 +1000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=20=D0=B0=D1=82=D1=80=D0=B8=D0=B1?= =?UTF-8?q?=D1=83=D1=82=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atr/atrib.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 +}