@@ -13,7 +13,6 @@ import (
1313 "github.com/elastic/elastic-integration-corpus-generator-tool/pkg/genlib/config"
1414 "github.com/elastic/elastic-integration-corpus-generator-tool/pkg/genlib/fields"
1515 "math"
16- "math/rand"
1716 "regexp"
1817 "strconv"
1918 "strings"
@@ -235,14 +234,14 @@ func makeFloatFunc(fieldCfg ConfigField, field Field) func() float64 {
235234
236235 switch {
237236 case maxValue > 0 :
238- dummyFunc = func () float64 { return minValue + rand .Float64 ()* (maxValue - minValue ) }
237+ dummyFunc = func () float64 { return minValue + customRand .Float64 ()* (maxValue - minValue ) }
239238 case len (field .Example ) == 0 :
240- dummyFunc = func () float64 { return rand .Float64 () * 10 }
239+ dummyFunc = func () float64 { return customRand .Float64 () * 10 }
241240 default :
242241 totDigit := len (field .Example )
243242 max := math .Pow10 (totDigit )
244243 dummyFunc = func () float64 {
245- return rand .Float64 () * max
244+ return customRand .Float64 () * max
246245 }
247246 }
248247
@@ -261,14 +260,14 @@ func makeIntFunc(fieldCfg ConfigField, field Field) func() int64 {
261260
262261 switch {
263262 case maxValue > 0 :
264- dummyFunc = func () int64 { return rand .Int63n (maxValue - minValue ) + minValue }
263+ dummyFunc = func () int64 { return customRand .Int63n (maxValue - minValue ) + minValue }
265264 case len (field .Example ) == 0 :
266- dummyFunc = func () int64 { return rand .Int63n (10 ) }
265+ dummyFunc = func () int64 { return customRand .Int63n (10 ) }
267266 default :
268267 totDigit := len (field .Example )
269268 max := int64 (math .Pow10 (totDigit ))
270269 dummyFunc = func () int64 {
271- return rand .Int63n (max )
270+ return customRand .Int63n (max )
272271 }
273272 }
274273
@@ -340,30 +339,30 @@ func genNounsNWithReturn(n int) string {
340339}
341340
342341func randGeoPoint (buf * bytes.Buffer ) error {
343- lat := rand .Intn (181 ) - 90
342+ lat := customRand .Intn (181 ) - 90
344343 var latD int
345344 if lat != - 90 && lat != 90 {
346- latD = rand .Intn (100 )
345+ latD = customRand .Intn (100 )
347346 }
348347 var longD int
349- long := rand .Intn (361 ) - 180
348+ long := customRand .Intn (361 ) - 180
350349 if long != - 180 && long != 180 {
351- longD = rand .Intn (100 )
350+ longD = customRand .Intn (100 )
352351 }
353352 _ , err := fmt .Fprintf (buf , "%d.%d,%d.%d" , lat , latD , long , longD )
354353 return err
355354}
356355
357356func randGeoPointWithReturn () string {
358- lat := rand .Intn (181 ) - 90
357+ lat := customRand .Intn (181 ) - 90
359358 var latD int
360359 if lat != - 90 && lat != 90 {
361- latD = rand .Intn (100 )
360+ latD = customRand .Intn (100 )
362361 }
363362 var longD int
364- long := rand .Intn (361 ) - 180
363+ long := customRand .Intn (361 ) - 180
365364 if long != - 180 && long != 180 {
366- longD = rand .Intn (100 )
365+ longD = customRand .Intn (100 )
367366 }
368367
369368 return fmt .Sprintf ("%d.%d,%d.%d" , lat , latD , long , longD )
@@ -390,7 +389,7 @@ func bindKeyword(fieldCfg ConfigField, field Field, fieldMap map[string]any) err
390389 if len (fieldCfg .Enum ) > 0 {
391390 var emitFNotReturn emitFNotReturn
392391 emitFNotReturn = func (state * GenState , buf * bytes.Buffer ) error {
393- idx := rand .Intn (len (fieldCfg .Enum ))
392+ idx := customRand .Intn (len (fieldCfg .Enum ))
394393 buf .WriteString (fieldCfg .Enum [idx ])
395394 return nil
396395 }
@@ -462,7 +461,7 @@ func bindStatic(field Field, v any, fieldMap map[string]any) error {
462461func bindBool (field Field , fieldMap map [string ]any ) error {
463462 var emitFNotReturn emitFNotReturn
464463 emitFNotReturn = func (state * GenState , buf * bytes.Buffer ) error {
465- switch rand .Int () % 2 {
464+ switch customRand .Int () % 2 {
466465 case 0 :
467466 buf .WriteString ("false" )
468467 case 1 :
@@ -488,7 +487,7 @@ func bindGeoPoint(field Field, fieldMap map[string]any) error {
488487func bindWordN (field Field , n int , fieldMap map [string ]any ) error {
489488 var emitFNotReturn emitFNotReturn
490489 emitFNotReturn = func (state * GenState , buf * bytes.Buffer ) error {
491- genNounsN (rand .Intn (n ), buf )
490+ genNounsN (customRand .Intn (n ), buf )
492491 return nil
493492 }
494493
@@ -503,7 +502,7 @@ func bindNearTime(fieldCfg ConfigField, field Field, fieldMap map[string]any) er
503502 if fieldCfg .Period > 0 && state .totEvents > 0 {
504503 offset = time .Duration ((fieldCfg .Period .Nanoseconds () / int64 (state .totEvents )) * int64 (state .counter ))
505504 } else {
506- offset = time .Duration (rand .Intn (FieldTypeTimeRange )* - 1 ) * time .Second
505+ offset = time .Duration (customRand .Intn (FieldTypeTimeRange )* - 1 ) * time .Second
507506 }
508507
509508 newTime := timeNowToBind .Add (offset )
@@ -518,10 +517,10 @@ func bindNearTime(fieldCfg ConfigField, field Field, fieldMap map[string]any) er
518517func bindIP (field Field , fieldMap map [string ]any ) error {
519518 var emitFNotReturn emitFNotReturn
520519 emitFNotReturn = func (state * GenState , buf * bytes.Buffer ) error {
521- i0 := rand .Intn (255 )
522- i1 := rand .Intn (255 )
523- i2 := rand .Intn (255 )
524- i3 := rand .Intn (255 )
520+ i0 := customRand .Intn (255 )
521+ i1 := customRand .Intn (255 )
522+ i2 := customRand .Intn (255 )
523+ i3 := customRand .Intn (255 )
525524
526525 _ , err := fmt .Fprintf (buf , "%d.%d.%d.%d" , i0 , i1 , i2 , i3 )
527526 return err
@@ -537,7 +536,7 @@ func fuzzyInt(previous int64, fuzziness, min, max float64) int64 {
537536 higherBound := float64 (previous ) * (1 + fuzziness )
538537 lowerBound = math .Max (lowerBound , min )
539538 higherBound = math .Min (higherBound , max )
540- return rand .Int63n (int64 (math .Ceil (higherBound - lowerBound ))) + int64 (lowerBound )
539+ return customRand .Int63n (int64 (math .Ceil (higherBound - lowerBound ))) + int64 (lowerBound )
541540}
542541
543542func bindLong (fieldCfg ConfigField , field Field , fieldMap map [string ]any ) error {
@@ -587,7 +586,7 @@ func fuzzyFloat(previous, fuzziness, min, max float64) float64 {
587586 higherBound := previous * (1 + fuzziness )
588587 lowerBound = math .Max (lowerBound , min )
589588 higherBound = math .Min (higherBound , max )
590- return lowerBound + rand .Float64 ()* (higherBound - lowerBound )
589+ return lowerBound + customRand .Float64 ()* (higherBound - lowerBound )
591590}
592591
593592func bindDouble (fieldCfg ConfigField , field Field , fieldMap map [string ]any ) error {
@@ -739,7 +738,7 @@ func bindKeywordWithReturn(fieldCfg ConfigField, field Field, fieldMap map[strin
739738 if len (fieldCfg .Enum ) > 0 {
740739 var emitF EmitF
741740 emitF = func (state * GenState ) any {
742- idx := rand .Intn (len (fieldCfg .Enum ))
741+ idx := customRand .Intn (len (fieldCfg .Enum ))
743742 return fieldCfg .Enum [idx ]
744743 }
745744
@@ -804,7 +803,7 @@ func bindStaticWithReturn(field Field, v any, fieldMap map[string]any) error {
804803func bindBoolWithReturn (field Field , fieldMap map [string ]any ) error {
805804 var emitF EmitF
806805 emitF = func (state * GenState ) any {
807- switch rand .Int () % 2 {
806+ switch customRand .Int () % 2 {
808807 case 0 :
809808 return false
810809 default :
@@ -830,7 +829,7 @@ func bindGeoPointWithReturn(field Field, fieldMap map[string]any) error {
830829func bindWordNWithReturn (field Field , n int , fieldMap map [string ]any ) error {
831830 var emitF EmitF
832831 emitF = func (state * GenState ) any {
833- return genNounsNWithReturn (rand .Intn (n ))
832+ return genNounsNWithReturn (customRand .Intn (n ))
834833 }
835834 fieldMap [field .Name ] = emitF
836835 return nil
@@ -843,7 +842,7 @@ func bindNearTimeWithReturn(fieldCfg ConfigField, field Field, fieldMap map[stri
843842 if fieldCfg .Period > 0 {
844843 offset = time .Duration ((fieldCfg .Period .Nanoseconds () / int64 (state .totEvents )) * int64 (state .counter ))
845844 } else {
846- offset = time .Duration (rand .Intn (FieldTypeTimeRange )* - 1 ) * time .Second
845+ offset = time .Duration (customRand .Intn (FieldTypeTimeRange )* - 1 ) * time .Second
847846 }
848847
849848 newTime := timeNowToBind .Add (offset )
@@ -857,10 +856,10 @@ func bindNearTimeWithReturn(fieldCfg ConfigField, field Field, fieldMap map[stri
857856func bindIPWithReturn (field Field , fieldMap map [string ]any ) error {
858857 var emitF EmitF
859858 emitF = func (state * GenState ) any {
860- i0 := rand .Intn (255 )
861- i1 := rand .Intn (255 )
862- i2 := rand .Intn (255 )
863- i3 := rand .Intn (255 )
859+ i0 := customRand .Intn (255 )
860+ i1 := customRand .Intn (255 )
861+ i2 := customRand .Intn (255 )
862+ i3 := customRand .Intn (255 )
864863
865864 return fmt .Sprintf ("%d.%d.%d.%d" , i0 , i1 , i2 , i3 )
866865 }
0 commit comments