mirror of https://github.com/gorilla/websocket.git
Use empty struct instead of bool in map value
This commit is contained in:
parent
cdedf21e58
commit
dad49c62a4
|
@ -8,7 +8,7 @@ package main
|
|||
// clients.
|
||||
type Hub struct {
|
||||
// Registered clients.
|
||||
clients map[*Client]bool
|
||||
clients map[*Client]struct{}
|
||||
|
||||
// Inbound messages from the clients.
|
||||
broadcast chan []byte
|
||||
|
@ -25,7 +25,7 @@ func newHub() *Hub {
|
|||
broadcast: make(chan []byte),
|
||||
register: make(chan *Client),
|
||||
unregister: make(chan *Client),
|
||||
clients: make(map[*Client]bool),
|
||||
clients: make(map[*Client]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ func (h *Hub) run() {
|
|||
for {
|
||||
select {
|
||||
case client := <-h.register:
|
||||
h.clients[client] = true
|
||||
h.clients[client] = struct{}{}
|
||||
case client := <-h.unregister:
|
||||
if _, ok := h.clients[client]; ok {
|
||||
delete(h.clients, client)
|
||||
|
|
Loading…
Reference in New Issue