Documentation ¶
Index ¶
- func BuildUrl(host, path string, query map[string]string) string
- func NewDeterministicRand(hash []byte) *rand.Rand
- func QueryParamBool(c echo.Context, name string) bool
- func QueryParamInt64(c echo.Context, name string) (int64, error)
- func RandomID(numberOnly bool, length int, isTaken func(string) bool) string
- func RandomString(numberOnly bool, length int) string
- func RemoveAccents(s string) string
- func SQLError(err error) error
- func SampleIndex(weights []float64) int
- func WebsocketError(ws *websocket.Conn, err error)
- type Shuffler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDeterministicRand ¶
func QueryParamBool ¶
QueryParamBool parse the query param `name` to a boolean
func QueryParamInt64 ¶
QueryParamInt64 parse the query param `name` to an int64
func RandomString ¶
func RemoveAccents ¶
func SampleIndex ¶
Sample choose an index between 0 and len(weights)-1 at random, with the given weights, which must sum up to 1.
func WebsocketError ¶
WebsocketError format `err` and send a Control message to `ws`
Types ¶
type Shuffler ¶
type Shuffler []int
Shuffler is a permutation used to shuffle a slice, storing the shuffled to original indices map.
func NewDeterministicShuffler ¶
NewDeterministicShuffler returns a random permutation of length `n`, seeded with a value computed from `hash`. The seed is adjusted to make sure the permuation is not the identity (unless n <= 1).
func (Shuffler) OriginalToShuffled ¶
OriginalToShuffled reverse the permutation, returning the original index -> shuffled index map.