finish product list api

This commit is contained in:
laodaming
2023-06-05 10:18:31 +08:00
parent 92b29d8006
commit 94212b1003
2 changed files with 29 additions and 6 deletions

View File

@@ -0,0 +1,21 @@
package format
import (
"strconv"
)
// 字符串切片转int切片
func StrSlicToIntSlice(input []string) ([]int, error) {
priceSlic := make([]int, 0, len(input))
for _, p := range input {
if p == "" {
continue
}
price, err := strconv.Atoi(p)
if err != nil {
return nil, err
}
priceSlic = append(priceSlic, price)
}
return priceSlic, nil
}