1 Star 0 Fork 0

Andyfoo / go-xutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
xmath.go 994 Bytes
一键复制 编辑 原始数据 按行查看 历史
Andyfoo 提交于 2019-09-21 00:47 . update
// Copyright 2019 Andyfoo
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package xmath
import (
"math/rand"
"time"
)
func RandInt64(min, max int64) int64 {
if min >= max || min == 0 || max == 0 {
return max
}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
return r.Int63n(max-min) + min
}
func RandInt(min, max int) int {
if min >= max || min == 0 || max == 0 {
return max
}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
return r.Intn(max-min) + min
}
Go
1
https://gitee.com/andyfoo/go-xutils.git
git@gitee.com:andyfoo/go-xutils.git
andyfoo
go-xutils
go-xutils
v1.0.7

搜索帮助

53164aa7 5694891 3bd8fe86 5694891