From 21fb2ad597f2a629dfaba40afd87d07aaf99c4f4 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sun, 18 Sep 2022 05:36:24 +0100 Subject: [PATCH] refactor example in readme --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1037b0a..448487e 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,7 @@ import ( ) func main() { - vm, err := voicemeeter.NewRemote("banana", 15) - if err != nil { - log.Fatal(err) - } - - err = vm.Login() + vm, err := vmConnect() if err != nil { log.Fatal(err) } @@ -57,6 +52,20 @@ func main() { vm.Strip[0].SetMute(true) fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute()) } + +func vmConnect() (*voicemeeter.Remote, error) { + vm, err := voicemeeter.NewRemote("banana", 15) + if err != nil { + return nil, err + } + + err = vm.Login() + if err != nil { + return nil, err + } + + return vm, nil +} ``` ## `voicemeeter.NewRemote(, )`