Skip to content

v1.1.4

Choose a tag to compare

@rsms rsms released this 17 Sep 15:48
· 53 commits to master since this release

Very minor update that makes it possible to use a zero Handlers struct instead of going through the NewHandlers function. This makes it easier to allocate Handlers for example as part of another, parent struct.

Example:

type MyThing struct {
  Gotalk gotalk.Handlers
  myOtherThing Thing
}
func main() {
  thing := MyThing{}
  thing.Gotalk.Handle("foo", ...)
  thing.Start()
}
func (m *MyThing) Start() {
  gotalk := gotalk.WebSocketHandler()
  gotalk.Handlers = &m.Gotalk
}

Prior to v1.1.4 you would have to do something like this instead, allocating a Handlers struct via the NewHandlers function:

type MyThing struct {
  Gotalk *gotalk.Handlers
  myOtherThing Thing
}
func NewMyThing() *MyThing {
  return &MyThing{ Gotalk: gotalk.NewHandlers() }
}
func main() {
  thing := NewMyThing()
  thing.Gotalk.Handle("foo", ...)
  thing.Start()
}
func (m *MyThing) Start() {
  gotalk := gotalk.WebSocketHandler()
  gotalk.Handlers = &m.Gotalk
}