diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index 430fb4783..94ef8f12a 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -6,7 +6,7 @@ require ( github.com/gogf/gf/contrib/drivers/mssql/v2 v2.0.0-rc2 github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.0.0-rc2 github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.0.0-rc2 - github.com/gogf/gf/v2 v2.0.0-rc + github.com/gogf/gf/v2 v2.0.0 github.com/olekukonko/tablewriter v0.0.5 ) diff --git a/util/grand/grand.go b/util/grand/grand.go index 77478cee4..34554a2f5 100644 --- a/util/grand/grand.go +++ b/util/grand/grand.go @@ -60,16 +60,12 @@ func N(min, max int) int { return min } if min >= 0 { - // Because Intn dose not support negative number, - // so we should first shift the value to left, - // then call Intn to produce the random number, - // and finally shift the result back to right. - return Intn(max-(min-0)+1) + (min - 0) + return Intn(max-min+1) + min } if min < 0 { - // Because Intn dose not support negative number, + // As `Intn` dose not support negative number, // so we should first shift the value to right, - // then call Intn to produce the random number, + // then call `Intn` to produce the random number, // and finally shift the result back to left. return Intn(max+(0-min)+1) - (0 - min) }