提交 0b2c74e6 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

improve random logic

上级 26c37499
......@@ -39,7 +39,7 @@ func GetRandFromRange(dataType, start, end, step string, repeat int, repeatTag,
stepInt = stepInt * -1
}
countInRound := (endInt-startInt)/stepInt + 1
countInRound := (endInt - startInt) / stepInt
for i := 0; i < count; i++ {
rand := commonUtils.RandNum64(countInRound)
......@@ -72,7 +72,7 @@ func GetRandFromRange(dataType, start, end, step string, repeat int, repeatTag,
stepInt = stepInt * -1
}
countInRound := (int64(endChar)-int64(startChar))/stepInt + 1
countInRound := (int64(endChar) - int64(startChar)) / stepInt
for i := 0; i < count; i++ {
rand := commonUtils.RandNum64(countInRound)
......@@ -106,7 +106,7 @@ func GetRandFromRange(dataType, start, end, step string, repeat int, repeatTag,
stepFloat = stepFloat * -1
}
countInRound := (endFloat-startFloat)/stepFloat + 1
countInRound := (endFloat - startFloat) / stepFloat
for i := 0; i < count; i++ {
rand := commonUtils.RandNum64(int64(countInRound))
......
go run src/zd.go -y demo/article.yaml -c 3 -head -s
rsrc -manifest xdoc/main.exe.manifest -ico xdoc/fav.ico -o zd.syso
生成数据的地方:
随机数生成:
实现:
gen/helper/rand.go 统一生成随机数,在最后的数据打印时,替换占位巢。
调用:
Print -> replacePlaceholder -> getValForPlaceholder -> helper.GetRandFromRange
非随机数生成:
实现:
GenerateIntItems -> generateIntItemsByStep | generateIntItemsRand
GenerateFloatItems -> generateFloatItemsByStep | generateFloatItemsRand
GenerateByteItems -> generateByteItemsByStep | generateByteItemsRand
调用:toGen -> Generate | CreateValuesFromYaml -> GenerateOnTopLevel
-> GenerateFieldValuesForDef -> CreateField -> CreateListField
-> CreateListFieldValues -> CreateFieldValuesFromList -> CreateValuesFromInterval
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册