add core/error/util files

This commit is contained in:
MaysWind
2020-10-17 17:22:10 +08:00
parent e5953c9f17
commit 6ad0a02d44
25 changed files with 917 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
package utils
import (
"crypto/rand"
"math/big"
)
func GetRandomInteger(max int) (int, error) {
result, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
return 0, err
}
return int(result.Int64()), nil
}