Skip to content

Commit

Permalink
feat(插件): 值增加字符串列表功能
Browse files Browse the repository at this point in the history
  • Loading branch information
storezhang committed Jan 24, 2024
1 parent 33b14b1 commit 9dae5df
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/internal/constant/string.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package constant

const Common = ","
18 changes: 18 additions & 0 deletions internal/internal/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package internal

import (
"strconv"
"strings"
"time"

"github.com/dronestock/drone/internal/internal/constant"
)

type Value struct {
Expand Down Expand Up @@ -32,3 +35,18 @@ func (v *Value) Time() (timestamp time.Time) {

return
}

func (v *Value) Slices() (result []string) {
items := strings.Split(v.content, constant.Common)
if 0 != len(items) {
result = make([]string, 0, len(items))
}
for _, item := range items {
finally := strings.TrimSpace(item)
if "" != finally {
result = append(result, finally)
}
}

return
}

0 comments on commit 9dae5df

Please sign in to comment.