diff --git a/shared/utils/fileutil/fileutil.go b/shared/utils/fileutil/fileutil.go index d62b796c3dd4faa9b4f105eab50aac702a44d5c1..bf425c3158164b2b7c8b0ebb2f5631ecb65912e0 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") }