From 7afd15cf0e617fe3f29637769a02ab5179161e65 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 30 Aug 2019 09:54:23 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96dao.GenQuestionMarks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/dao_utils.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/business/model/dao/dao_utils.go b/business/model/dao/dao_utils.go index c1a0c6ed0..b45b4386c 100644 --- a/business/model/dao/dao_utils.go +++ b/business/model/dao/dao_utils.go @@ -73,12 +73,18 @@ func WrapUpdateULEntity(item interface{}, lastOperator string) interface{} { return item } -func GenQuestionMarks(count int) string { - marks := "" +func GenQuestionMarks(count int) (marks string) { if count > 0 { - marks = "?" - for i := 1; i < count; i++ { - marks += ", ?" + if count == 1 { + marks = "?" + } else { + builder := &strings.Builder{} + builder.Grow(1 + (count-1)*3) + builder.WriteString("?") + for i := 1; i < count; i++ { + builder.WriteString(", ?") + } + marks = builder.String() } } return marks