package io_utils import ( "errors" "os" ) var ( ErrReadingFile = errors.New("error while reading the file") ErrFileEmpty = errors.New("provided file is empty") ) func ReadPassFile(path string) (pass string, err error) { buff, err := os.ReadFile(path) if err != nil { return "", errors.Join(ErrReadingFile, err) } if len(buff) < 1 { return "", ErrFileEmpty } if buff[len(buff)-1] == '\n' { buff = buff[:len(buff)-1] } return string(buff), nil }