Created
January 9, 2014 01:22
-
-
Save capoferro/8327802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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