Skip to content

Instantly share code, notes, and snippets.

@capoferro
Created January 9, 2014 01:22
Show Gist options
  • Save capoferro/8327802 to your computer and use it in GitHub Desktop.
Save capoferro/8327802 to your computer and use it in GitHub Desktop.
func AllPlayers() []*Player {
ikeys, _ := conn().Do("KEYS", playerTag + "*:item_list")
keys := make([]string, 0)
// OH MY GOD. I have no idea how to convert ikeys to a slice of
// strings. This feels incredibly dirty.
for _, key := range ikeys.([]interface{}) {
keys = append(keys, string(key.([]uint8)))
}
players := make([]*Player, 0)
for _, key := range keys {
tokens := strings.Split(key, ":")
if len(tokens) == 3 {
players = append(players, NewPlayer(tokens[1]))
}
}
return players
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment