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 }