diff --git a/examples/hotkeys/main.go b/examples/hotkeys/main.go index fa51c8a..ae3b4e3 100644 --- a/examples/hotkeys/main.go +++ b/examples/hotkeys/main.go @@ -10,18 +10,13 @@ import ( func main() { if err := keyboard.Open(); err != nil { - panic(err) + log.Fatal(err) } defer func() { _ = keyboard.Close() }() - vm, err := voicemeeter.NewRemote("potato", 0) - if err != nil { - log.Fatal(err) - } - - err = vm.Login() + vm, err := vmConnect() if err != nil { log.Fatal(err) } @@ -55,3 +50,17 @@ Loop: } } } + +func vmConnect() (*voicemeeter.Remote, error) { + vm, err := voicemeeter.NewRemote("potato", 0) + if err != nil { + return nil, err + } + + err = vm.Login() + if err != nil { + return nil, err + } + + return vm, nil +}