From 2b9276704c193de1b6ea8f47eb8aaaf9148c79e3 Mon Sep 17 00:00:00 2001
From: Simon Kirsten <simon.kirsten@stud.h-da.de>
Date: Fri, 29 Nov 2019 03:04:48 +0100
Subject: [PATCH] Moved DefaultTwitchClientID and Version to config

---
 cmd/stream-server/main.go |  3 ++-
 config.go                 | 10 ++++++++++
 internal/server/server.go |  3 ---
 internal/server/twitch.go |  7 ++-----
 4 files changed, 14 insertions(+), 9 deletions(-)
 create mode 100644 config.go

diff --git a/cmd/stream-server/main.go b/cmd/stream-server/main.go
index 29c5913..ca79330 100644
--- a/cmd/stream-server/main.go
+++ b/cmd/stream-server/main.go
@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"log"
 	"os"
+	streamserver "stream-server"
 
 	"github.com/urfave/cli"
 
@@ -24,7 +25,7 @@ func main() {
 	app.Usage = docURL
 	app.HideHelp = true
 
-	app.Version = server.Version
+	app.Version = streamserver.Version
 
 	app.Flags = []cli.Flag{
 		cli.IntFlag{
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..d307b38
--- /dev/null
+++ b/config.go
@@ -0,0 +1,10 @@
+package streamserver
+
+// For pager to work we need at least one .go file in the main folder so thats why this exists :)
+
+// Version will automatically be set by the CI pipeline.
+var Version = "dev"
+
+// DefaultTwitchClientID will automatically be set by the CI pipeline.
+// for local builds the TWITCH_CLIENT_ID environment variable must be set
+var DefaultTwitchClientID = ""
diff --git a/internal/server/server.go b/internal/server/server.go
index 1ca5048..238afbf 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -7,9 +7,6 @@ import (
 	"github.com/markbates/pkger"
 )
 
-// Version will automatically be set by the CI pipeline.
-var Version = "dev"
-
 // ListenAndServe will listen and serve on the provided listenAddr
 func ListenAndServe(listenAddr string) error {
 	r := chi.NewRouter()
diff --git a/internal/server/twitch.go b/internal/server/twitch.go
index a2eb569..93a2809 100644
--- a/internal/server/twitch.go
+++ b/internal/server/twitch.go
@@ -3,6 +3,7 @@ package server
 import (
 	"net/http"
 	"os"
+	streamserver "stream-server"
 
 	"stream-server/internal/util"
 	"stream-server/pkg/twitch"
@@ -11,17 +12,13 @@ import (
 // client is the Twitch Client instance
 var client *twitch.Client
 
-// defaultTwitchClientID will automatically be set by the CI pipeline.
-// for local builds the TWITCH_CLIENT_ID environment variable must be set
-var defaultTwitchClientID string
-
 func init() {
 	// If you want to use your own twitch client id set the TWITCH_CLIENT_ID environment variable.
 
 	if twitchClientID := os.Getenv("TWITCH_CLIENT_ID"); twitchClientID != "" {
 		client = twitch.NewClient(twitchClientID)
 	} else {
-		client = twitch.NewClient(defaultTwitchClientID)
+		client = twitch.NewClient(streamserver.DefaultTwitchClientID)
 	}
 }
 
-- 
GitLab