From ccb8b25452e73787ce77867dd67dae70764addf5 Mon Sep 17 00:00:00 2001
From: zachmann <gabriel.zachmann@kit.edu>
Date: Tue, 3 May 2022 14:58:38 +0200
Subject: [PATCH] add util function to read file that is not config file

---
 shared/utils/fileutil/fileutil.go | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/shared/utils/fileutil/fileutil.go b/shared/utils/fileutil/fileutil.go
index d62b796c..bf425c31 100644
--- a/shared/utils/fileutil/fileutil.go
+++ b/shared/utils/fileutil/fileutil.go
@@ -51,12 +51,16 @@ func Append(path, content string, doNotCreateIfDoesNotExist ...bool) error {
 	return err
 }
 
-// MustReadFile reads a given config file and returns the content. If an error
-// occurs mytoken terminates.
-func MustReadFile(filename string) []byte {
+// ReadFile reads a given file and returns the content.
+func ReadFile(filename string) ([]byte, error) {
 	filename = evalSymlink(filename)
-	log.WithField("filepath", filename).Trace("Found file. Reading config file ...")
-	file, err := os.ReadFile(filename)
+	log.WithField("filepath", filename).Trace("Reading file...")
+	return os.ReadFile(filename)
+}
+
+// MustReadFile reads a given file and returns the content. If an error occurs mytoken terminates.
+func MustReadFile(filename string) []byte {
+	file, err := ReadFile(filename)
 	if err != nil {
 		log.WithError(err).Fatal("Error reading config file")
 	}
-- 
GitLab