Skip to content
Snippets Groups Projects
Verified Commit ccb8b254 authored by Gabriel Zachmann's avatar Gabriel Zachmann
Browse files

add util function to read file that is not config file

parent 15e391d5
No related branches found
No related tags found
No related merge requests found
...@@ -51,12 +51,16 @@ func Append(path, content string, doNotCreateIfDoesNotExist ...bool) error { ...@@ -51,12 +51,16 @@ func Append(path, content string, doNotCreateIfDoesNotExist ...bool) error {
return err return err
} }
// MustReadFile reads a given config file and returns the content. If an error // ReadFile reads a given file and returns the content.
// occurs mytoken terminates. func ReadFile(filename string) ([]byte, error) {
func MustReadFile(filename string) []byte {
filename = evalSymlink(filename) filename = evalSymlink(filename)
log.WithField("filepath", filename).Trace("Found file. Reading config file ...") log.WithField("filepath", filename).Trace("Reading file...")
file, err := os.ReadFile(filename) 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 { if err != nil {
log.WithError(err).Fatal("Error reading config file") log.WithError(err).Fatal("Error reading config file")
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment