use log.Fatal during setup procedures.

update readme example
This commit is contained in:
onyx-and-iris 2022-08-23 03:35:34 +01:00
parent 6fabc43998
commit 7a79555cb8
5 changed files with 14 additions and 15 deletions

View File

@ -42,21 +42,24 @@ package main
import ( import (
"fmt" "fmt"
"log"
"github.com/onyx-and-iris/voicemeeter-api-go" "github.com/onyx-and-iris/voicemeeter-api-go"
) )
func main() { func main() {
kindId := "banana" kindId := "banana"
vm := voicemeeter.NewRemote(kindId) vm, err := voicemeeter.NewRemote(kindId)
if err != nil {
log.Fatal(err)
}
defer vm.Logout()
vm.Login() vm.Login()
vm.Strip[0].SetLabel("rode podmic") vm.Strip[0].SetLabel("rode podmic")
vm.Strip[0].SetMute(true) vm.Strip[0].SetMute(true)
fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute()) fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute())
vm.Logout()
} }
``` ```

View File

@ -2,7 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"os" "log"
"time" "time"
"github.com/onyx-and-iris/voicemeeter-api-go" "github.com/onyx-and-iris/voicemeeter-api-go"
@ -49,8 +49,7 @@ func (o observer) OnUpdate(subject string) {
func main() { func main() {
vm, err := voicemeeter.NewRemote("potato") vm, err := voicemeeter.NewRemote("potato")
if err != nil { if err != nil {
fmt.Println(err) log.Fatal(err)
os.Exit(1)
} }
defer vm.Logout() defer vm.Logout()

View File

@ -1,7 +1,7 @@
package voicemeeter package voicemeeter
import ( import (
"fmt" "log"
"os" "os"
"testing" "testing"
"time" "time"
@ -13,8 +13,7 @@ var (
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
if err != nil { if err != nil {
fmt.Println(err) log.Fatal(err)
os.Exit(1)
} }
vm.Login() vm.Login()

View File

@ -3,7 +3,7 @@ package voicemeeter
import ( import (
"errors" "errors"
"fmt" "fmt"
"os" "log"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
@ -49,8 +49,7 @@ func dllPath() (string, error) {
func getDllPath() string { func getDllPath() string {
path, err := dllPath() path, err := dllPath()
if err != nil { if err != nil {
fmt.Println(err) log.Fatal(err)
os.Exit(1)
} }
return path return path
} }

View File

@ -1,7 +1,7 @@
package voicemeeter_test package voicemeeter_test
import ( import (
"fmt" "log"
"os" "os"
"testing" "testing"
"time" "time"
@ -15,8 +15,7 @@ var (
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
if err != nil { if err != nil {
fmt.Println(err) log.Fatal(err)
os.Exit(1)
} }
defer vm.Logout() defer vm.Logout()