From a2b3468a6c36f79bbbf17520dd851968cacb9a50 Mon Sep 17 00:00:00 2001 From: YanR <1138002326@qq.com> Date: Mon, 28 Aug 2023 18:11:12 +0800 Subject: [PATCH] =?UTF-8?q?common=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/utils.go b/utils.go index 08bedfb..ecdac2c 100644 --- a/utils.go +++ b/utils.go @@ -3,6 +3,7 @@ package common import ( "math" "strconv" + "strings" ) func StringToArray(input string) []int { @@ -57,3 +58,21 @@ func ConverToBinary(n int) string { } return res } + +// 格式化页面传入的cartIds 方法提取 +func SplitToInt32List(str string, sep string) (int32List []int32) { + tempStr := strings.Split(str, sep) + if len(tempStr) > 0 { + for _, item := range tempStr { + if item == "" { + continue + } + val, err := strconv.ParseInt(item, 10, 32) + if err != nil { + continue + } + int32List = append(int32List, int32(val)) + } + } + return int32List +}