func makeIntFunc()

in pkg/genlib/generator_interface.go [250:274]


func makeIntFunc(fieldCfg ConfigField, field Field) func() int64 {
	minValue, _ := fieldCfg.Range.MinAsInt64()
	maxValue, err := fieldCfg.Range.MaxAsInt64()
	// maxValue not set, let's set it to 0 for the sake of the switch above
	if err != nil {
		maxValue = 0
	}

	var dummyFunc func() int64

	switch {
	case maxValue > 0:
		dummyFunc = func() int64 { return customRand.Int63n(maxValue-minValue) + minValue }
	case len(field.Example) == 0:
		dummyFunc = func() int64 { return customRand.Int63n(10) }
	default:
		totDigit := len(field.Example)
		max := int64(math.Pow10(totDigit))
		dummyFunc = func() int64 {
			return customRand.Int63n(max)
		}
	}

	return dummyFunc
}