Skip to content

A simple function which takes a map of weighted options and picks one at random. This might be useful for a lottery or raffle where participants might have multiple tickets.

License

Notifications You must be signed in to change notification settings

uberswe/randompick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RandomPick

A simple function which takes a map of weighted options and picks one at random. This might be useful for a lottery or raffle where participants might have multiple tickets.

rand.Seed(time.Now().UnixNano())

m := map[string]int{
    "Bob": 900,
    "Steve": 2000,
    "Kyle": 300,
}

fmt.Println(randompick.Result(m))

About

A simple function which takes a map of weighted options and picks one at random. This might be useful for a lottery or raffle where participants might have multiple tickets.

Topics

Resources

License

Stars

Watchers

Forks

Languages