Skip to content

Commit ccb8b25

Browse files
committed
add util function to read file that is not config file
1 parent 15e391d commit ccb8b25

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

shared/utils/fileutil/fileutil.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ func Append(path, content string, doNotCreateIfDoesNotExist ...bool) error {
5151
return err
5252
}
5353

54-
// MustReadFile reads a given config file and returns the content. If an error
55-
// occurs mytoken terminates.
56-
func MustReadFile(filename string) []byte {
54+
// ReadFile reads a given file and returns the content.
55+
func ReadFile(filename string) ([]byte, error) {
5756
filename = evalSymlink(filename)
58-
log.WithField("filepath", filename).Trace("Found file. Reading config file ...")
59-
file, err := os.ReadFile(filename)
57+
log.WithField("filepath", filename).Trace("Reading file...")
58+
return os.ReadFile(filename)
59+
}
60+
61+
// MustReadFile reads a given file and returns the content. If an error occurs mytoken terminates.
62+
func MustReadFile(filename string) []byte {
63+
file, err := ReadFile(filename)
6064
if err != nil {
6165
log.WithError(err).Fatal("Error reading config file")
6266
}

0 commit comments

Comments
 (0)