Skip to content

Instantly share code, notes, and snippets.

@gregtap
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save gregtap/15f8bab4c91e65dd3a29 to your computer and use it in GitHub Desktop.

Select an option

Save gregtap/15f8bab4c91e65dd3a29 to your computer and use it in GitHub Desktop.
src/ondemand/main.go:24: StasdClient declared and not used
package main
type hub struct {
// Registered connections.
connections map[*connection]bool
// Inbound messages from the connections.
broadcast chan []byte
// Register requests from the connections.
register chan *connection
// Unregister requests from connections.
unregister chan *connection
}
var h = hub{
broadcast: make(chan []byte),
register: make(chan *connection),
unregister: make(chan *connection),
connections: make(map[*connection]bool),
}
func (h *hub) run() {
for {
select {
// Register a connection (Websocket *, send []byte)
case c := <-h.register:
h.connections[c] = true
// HERE
StasdClient.Increment("bucket", 1, 1)
}
}
}
package main
import (
"fmt"
"github.com/cyberdelia/statsd"
"github.com/spf13/viper"
"log"
"net/http"
)
var StasdClient *statsd.Client
var err Error
func main() {
StasdClient, err = statsd.Dial("localhost:8125")
if err != nil {
log.Fatal("Cant connect to statsd")
}
// Start hub as a go routine.
go h.run()
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment