Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
UlricQin committed Jul 20, 2019
1 parent cc90e1b commit 157c3e6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions str/str.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package str

import "strings"

func TrimStringSlice(raw []string) []string {
if raw == nil {
return []string{}
}

cnt := len(raw)
arr := make([]string, 0, cnt)
for i := 0; i < cnt; i++ {
item := strings.TrimSpace(raw[i])
if item == "" {
continue
}

arr = append(arr, item)
}

return arr
}

0 comments on commit 157c3e6

Please sign in to comment.