Use direct assignment

This commit is contained in:
Julian Kornberger 2016-02-26 10:40:17 +01:00
parent 853e54065c
commit d2467bed77
3 changed files with 19 additions and 23 deletions

View File

@ -9,13 +9,12 @@ type Daemon struct {
//NewDaemon create a list of collectors
func NewDaemon(parseFunc func(coll *Collector, res *Response)) *Daemon {
collectors := []*Collector{
return &Daemon{
collectors: []*Collector{
NewCollector("statistics", parseFunc),
NewCollector("nodeinfo", parseFunc),
NewCollector("neighbours", parseFunc),
}
return &Daemon{
collectors,
},
}
}

View File

@ -31,10 +31,14 @@ func NewClient(ws *websocket.Conn, server *Server) *Client {
}
maxID++
ch := make(chan interface{}, channelBufSize)
doneCh := make(chan bool)
return &Client{maxID, ws, server, ch, doneCh}
return &Client{
id: maxID,
ws: ws,
server: server,
ch: make(chan interface{}, channelBufSize),
doneCh: make(chan bool),
}
}
//GetConnection the websocket connection of a listen client

View File

@ -21,21 +21,14 @@ type Server struct {
//NewServer creates a new server
func NewServer(pattern string) *Server {
clients := make(map[int]*Client)
addCh := make(chan *Client)
delCh := make(chan *Client)
sendAllCh := make(chan interface{})
closeCh := make(chan bool)
errCh := make(chan error)
return &Server{
pattern,
clients,
addCh,
delCh,
sendAllCh,
closeCh,
errCh,
pattern: pattern,
clients: make(map[int]*Client),
addCh: make(chan *Client),
delCh: make(chan *Client),
sendAllCh: make(chan interface{}),
closeCh: make(chan bool),
errCh: make(chan error),
}
}