D.R.Y: check for permissions error in common.ErrorCheck

Reduce cognitive complexity.
This commit is contained in:
kayos@tcp.direct 2024-06-18 18:38:28 -07:00
parent 2cec7b2e05
commit 0170b7cd90
No known key found for this signature in database
GPG key ID: 4B841471B4BEE979
3 changed files with 32 additions and 62 deletions

View file

@ -52,10 +52,6 @@ func ReadLines(fileName string) []string {
func ReadFile(fileName string) string {
// Read the whole file
content, err := os.ReadFile(fileName)
if errors.Is(err, os.ErrPermission) {
common.ErrorCheck(err, common.PermissionNotice)
return "" // note: unreachable due to ErrorCheck calling fatal
}
common.ErrorCheck(err, fmt.Sprintf("Failed to ReadFile on %s", fileName))
// Return all the lines as one string