From 912dfa62f2becbb5f2a6c56d7742af078d996be7 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Sun, 27 Oct 2024 17:03:28 +0100 Subject: [PATCH] format: improve code structure for better readability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 --- internal/helper/config.go | 4 ++++ internal/websocket/receive.go | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/helper/config.go b/internal/helper/config.go index 312e494..17e97ac 100644 --- a/internal/helper/config.go +++ b/internal/helper/config.go @@ -11,17 +11,21 @@ import ( func ParseConfig(filename string) ChronoTomato.Config { var config ChronoTomato.Config + if strings.HasPrefix(filename, "~/") { dirname, _ := os.UserHomeDir() filename = filepath.Join(dirname, filename[2:]) } + yamlFile, err := os.ReadFile(filename) if err != nil { log.Fatal("Error opening config file!", "reason", err) } + err = yaml.Unmarshal(yamlFile, &config) if err != nil { log.Fatalf("Unmarshal: %v", err) } + return config } diff --git a/internal/websocket/receive.go b/internal/websocket/receive.go index 3e96ca9..1474ccd 100644 --- a/internal/websocket/receive.go +++ b/internal/websocket/receive.go @@ -11,7 +11,6 @@ import ( var Done = make(chan struct{}) func ProcessServerMessages(conn *websocket.Conn, channel chan<- GoTomato.ServerMessage) { - var serverMessage GoTomato.ServerMessage defer close(Done)