diff --git a/respond/daemon.go b/respond/daemon.go index 241e809..5dd54b2 100644 --- a/respond/daemon.go +++ b/respond/daemon.go @@ -9,13 +9,12 @@ type Daemon struct { //NewDaemon create a list of collectors func NewDaemon(parseFunc func(coll *Collector, res *Response)) *Daemon { - collectors := []*Collector{ - NewCollector("statistics", parseFunc), - NewCollector("nodeinfo", parseFunc), - NewCollector("neighbours", parseFunc), - } return &Daemon{ - collectors, + collectors: []*Collector{ + NewCollector("statistics", parseFunc), + NewCollector("nodeinfo", parseFunc), + NewCollector("neighbours", parseFunc), + }, } } diff --git a/websocketserver/client.go b/websocketserver/client.go index abda9eb..e1d8fd4 100644 --- a/websocketserver/client.go +++ b/websocketserver/client.go @@ -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 diff --git a/websocketserver/server.go b/websocketserver/server.go index a779825..6712d80 100644 --- a/websocketserver/server.go +++ b/websocketserver/server.go @@ -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), } }