-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Hello,
I've been trying to use your library, and the notification handing system in it, but have come up against a strange issue. By default, Go seems to inline the NotifyHandler function, which for some reason breaks it, and so the function specified in it is never called.
I've fixed this locally by adding the compiler directive //go:noinline
above the NotifyHandler and NotifyHandlerString functions, but this is probably a hack rather than a long-term fix.
A minimal program to re-produce this can be found below:
package main
import (
"github.com/darfk/ts3"
"log"
)
func main() {
notification := make(chan ts3.Notification)
go processNotify(notification)
client, err := ts3.NewClient("ts3.example.com:10011")
if err != nil {
log.Fatal(err)
}
_, err = client.Exec(ts3.Login("gotest", "password"))
if err != nil {
log.Fatal(err)
}
_, err = client.Exec(ts3.Use(1))
if err != nil {
log.Fatal(err)
}
response, err := client.Exec(ts3.Command{
Command: "servernotifyregister",
Params: map[string][]string{
"event": []string{"channel"},
"id": []string{"1"},
},
})
if err != nil {
log.Fatal(err)
}
client.NotifyHandler( func(n ts3.Notification) {
log.Println(n)
})
for {
}
Build normally, with go build, then move from the root channel on teampseak to another, note no output.
But when built with go build -gcflags '-l'
, which disables inline optimization, the expected output is given.
Tested on Arch Linux, with go version 1.9.2