D.R.Y: check for permissions error in common.ErrorCheck
Reduce cognitive complexity.
This commit is contained in:
parent
2cec7b2e05
commit
0170b7cd90
3 changed files with 32 additions and 62 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue