I hereby claim:
- I am mkock on github.
- I am mkock (https://keybase.io/mkock) on keybase.
- I have a public key ASAZA0SygMgNgJLx_fZhwtso0TiCl2sLVre8QaPxH5U0owo
To claim this, I am signing this object:
| var ( | |
| playerIDMap = make(map[uint32]Player) | |
| playerHandleMap = make(map[string]Player) | |
| playerCountryMap = make(map[string][]Player) | |
| ) |
| // FindPlayerByID returns the player with the given ID, if exists. | |
| // Otherwise, an empty Player is returned. | |
| func FindPlayerByID(ID uint32) Player { | |
| if p, ok := playerIDMap[ID]; ok { | |
| return p | |
| } | |
| return Player{} | |
| } | |
| // FindPlayerByHandle returns the player with the given Handle, |
| var ( | |
| playerIDMap = make(map[uint32]Player) | |
| playerHandleMap = make(map[string]uint32) // ref: playerIDMap | |
| playerCountryMap = make(map[string][]uint32) // ref: playerIDMap | |
| ) |
| // FindPlayerByID returns the player with the given ID, if exists. | |
| // Otherwise, an empty Player is returned. | |
| func FindPlayerByID(ID uint32) Player { | |
| if p, ok := playerIDMap[ID]; ok { | |
| return p | |
| } | |
| return Player{} | |
| } | |
| // FindPlayerByHandle returns the player with the given Handle, |
| // cachedPlayer is a Player, but without the Games field. | |
| type cachedPlayer struct { | |
| ID uint32 | |
| Handle, Name, Country string | |
| } |
| var games = []string{"Flappy Fish", "Ducks'n'Dogs", "Backflip Pro"} | |
| var crashyGamesPlayers map[uint32]cachedPlayer |
| // convertWith returns the Player that matches cachedPlayer, | |
| // with game titles attached. | |
| func (c cachedPlayer) convertWith(games []string) Player { | |
| return Player{ | |
| ID: c.ID, | |
| Handle: c.Handle, | |
| Name: c.Name, | |
| Country: c.Country, | |
| Games: games, | |
| } |
| // FindPlayerByID returns the player with the given ID, if exists. | |
| // Otherwise, an empty Player is returned. | |
| func FindPlayerByID(ID uint32) Player { | |
| if cp, ok := crashyGamesPlayers[ID]; ok { | |
| // cachedPlayer found. | |
| return cp.convertWith(games) // Using globally cached games. | |
| } | |
| return Player{} | |
| } |
I hereby claim:
To claim this, I am signing this object:
| package busservice | |
| // Passenger represents a bus passenger, uniquely identified by their SSN. | |
| type Passenger struct { | |
| SSN string | |
| SeatNumber uint8 | |
| } | |
| // Bus carries Passengers from A to B if they have a valid bus ticket. | |
| type Bus struct { |