2022-08-12 14:45:06 +03:00
|
|
|
package atr
|
|
|
|
|
2022-08-13 09:50:20 +03:00
|
|
|
import "strings"
|
|
|
|
|
2022-08-12 14:45:06 +03:00
|
|
|
type Atr string
|
|
|
|
|
2022-08-13 09:50:20 +03:00
|
|
|
const sep Atr = ","
|
|
|
|
|
2022-08-12 14:45:06 +03:00
|
|
|
// New Atr
|
|
|
|
func New(a string) Atr {
|
|
|
|
return Atr(a)
|
|
|
|
}
|
|
|
|
|
|
|
|
//Glue slice Atr to Atr
|
2022-08-13 09:50:20 +03:00
|
|
|
func Glue(atr ...Atr) Atr {
|
2022-08-12 14:45:06 +03:00
|
|
|
var endatr Atr
|
|
|
|
lenatr := len(atr)
|
|
|
|
for _, a0 := range atr {
|
|
|
|
if a0 != "" {
|
|
|
|
endatr = endatr + a0
|
|
|
|
if lenatr > 1 {
|
2022-08-13 09:50:20 +03:00
|
|
|
endatr = endatr + sep
|
2022-08-12 14:45:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lenatr--
|
|
|
|
}
|
|
|
|
|
|
|
|
return endatr
|
|
|
|
}
|
2022-08-13 09:50:20 +03:00
|
|
|
|
|
|
|
//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
|
|
|
|
}
|