From bf5ec2041692da263592d8baa34b0bed62e14417 Mon Sep 17 00:00:00 2001 From: Matthieu Grieger Date: Fri, 17 Apr 2015 16:54:30 -0700 Subject: [PATCH] Add PerformStartupChecks() to check for YOUTUBE_API_KEY and other stuff in the future --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.go b/main.go index 05932ff..871ea4c 100644 --- a/main.go +++ b/main.go @@ -133,6 +133,15 @@ func (dj *mumbledj) SendPrivateMessage(user *gumble.User, message string) { } } +// PerformStartupChecks checks the MumbleDJ installation to ensure proper usage. +func PerformStartupChecks() { + if os.Getenv("YOUTUBE_API_KEY") == "" { + fmt.Printf("You do not have a YouTube API key defined in your environment variables.\n" + + "Please see the following link for info on how to fix this: https://github.com/matthieugrieger/mumbledj#youtube-api-keys\n") + os.Exit(1) + } +} + // dj variable declaration. This is done outside of main() to allow global use. var dj = mumbledj{ keepAlive: make(chan bool), @@ -145,6 +154,8 @@ var dj = mumbledj{ // args, sets up the gumble client and its listeners, and then connects to the server. func main() { + PerformStartupChecks() + if currentUser, err := user.Current(); err == nil { dj.homeDir = currentUser.HomeDir }