1 Star 0 Fork 0

sun/common_pkg

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
contribute
Sync branch
yzsunjianguo-yzsunjianguo yzsunjianguo init 0755d36 2 years ago
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README

krand

Generate random strings, integers, floating point numbers.


Example of use

Generate a random string

    import "gitee.com/jianguosun_admin/common_pkg/krand"

    /*
	R_NUM = 1      // only number
	R_UPPER = 2   // only capital letters
	R_LOWER = 4  // only lowercase letters
	R_All = 7	       // numbers, upper and lower case letters
    */

	// by | or combining different types
    kind := krand.R_NUM|krand.R_UPPER    // capital letters and numbers

	// a random string of length 10, consisting of upper case letters and numbers
    krand.String(kind, 10)

Generate random integers

    import "gitee.com/jianguosun_admin/common_pkg/krand"

    krand.Int(200)            // random number range 0 ~ 200
    krand.Int(1000, 2000)  // random number range 1000 ~ 2000

Generate random floating point numbers

    import "gitee.com/jianguosun_admin/common_pkg/krand"

    krand.Float64(1, 200)            // floating point number with 1 decimal point, range 0~200
    krand.Float64(2, 100,1000)            // floating point number with 2 decimal places, range 100~1000
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jianguosun_admin/common_pkg.git
git@gitee.com:jianguosun_admin/common_pkg.git
jianguosun_admin
common_pkg
common_pkg
master

Search