Skip to content

Instantly share code, notes, and snippets.

@motokiee
Created May 24, 2016 00:34
Show Gist options
  • Save motokiee/0578e32ca2f15a7c269bfe684d527350 to your computer and use it in GitHub Desktop.
Save motokiee/0578e32ca2f15a7c269bfe684d527350 to your computer and use it in GitHub Desktop.
型アサーションは(T, bool)を返すと #CodePiece
func (c *client) read() {
for {
var msg *message
if err := c.socket.ReadJSON(&msg); err == nil {
msg.When = time.Now()
msg.Name = c.userData["name"].(string)
if avatarURL, ok := c.userData["avatar_url"]; ok {
msg.AvatarURL = avatarURL.(string)
}
c.room.forward <- msg
} else {
break
}
}
c.socket.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment