Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoElementItem = errors.New("crypto/rand: no element item to pick")
ErrNoElementItem 列表裡沒有任何可用對象
Functions ¶
func RandBytes ¶
RandBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func RandInt ¶
RandInt returns an int64 securely generated random int64. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func RandString ¶
RandString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
Types ¶
type IntsRandPicker ¶
type IntsRandPicker struct {
// contains filtered or unexported fields
}
IntsRandPicker 隨機選取一個int值,直到全部int取完為止
func NewIntsRandPicker ¶
func NewIntsRandPicker(min, max int) *IntsRandPicker
NewIntsRandPicker 生成int隨機
func NewIntsRandPickerItems ¶
func NewIntsRandPickerItems(items ...int) *IntsRandPicker
NewIntsRandPickerItems 生成int隨機
func (*IntsRandPicker) Next ¶
func (irp *IntsRandPicker) Next() (int, error)
Next 隨機挑選下一個值,並且從待選數組裡面移除,非線程安全
func (*IntsRandPicker) Rand ¶
func (irp *IntsRandPicker) Rand() (int, error)
Rand 隨機挑選下一個值,但是不從數組裡移除,非線程安全
type RandPicker ¶
type RandPicker interface {
//Add 增加一個選項
Add(items ...interface{})
//HasNext 是否還有下一個對象
HasNext() bool
//隨機挑選下一個值,並且從待選數組裡面移除
Next() (interface{}, error)
//隨機挑選一個值,但是不做移除
Rand() (interface{}, error)
}
RandPicker 數組隨機項抽取器