Skip to content

Commit

Permalink
Refactoring code, renaming rndInt to value and removing unreachable code
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswdr committed Jan 20, 2024
1 parent 4c0eb68 commit 68b63ce
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions faker.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,17 @@ func (f Faker) UInt64() uint64 {
// IntBetween returns a fake Int between a given minimum and maximum values for Faker
func (f Faker) IntBetween(min, max int) int {
diff := max - min
var rndInt int

var value int
if diff == 0 {
return min
} else if diff < 0 {
diff = -1 * diff
} else if diff >= math.MaxInt {
rndInt = f.Generator.Intn(diff)
} else {
rndInt = f.Generator.Intn(diff + 1)
} else if diff == math.MaxInt {
value = f.Generator.Intn(diff)
} else if diff > 0 {
value = f.Generator.Intn(diff + 1)
}

return min + rndInt
return min + value
}

// Int8Between returns a fake Int8 between a given minimum and maximum values for Faker
Expand Down

0 comments on commit 68b63ce

Please sign in to comment.