Fix golang-ci gocritic error

It should fix this error:
`nilValReturn: returned expr is always nil; replace err with nil`
This commit is contained in:
Panagiotis Georgiadis 2021-03-26 18:52:43 +01:00
parent ecab467a0f
commit 4558da0136
No known key found for this signature in database
GPG Key ID: A5B9AF563B15B24F
1 changed files with 18 additions and 15 deletions

View File

@ -4,6 +4,7 @@ import (
"bufio"
"errors"
"fmt"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
@ -181,14 +182,13 @@ func (mpq *MPQ) Size() uint32 {
func openIgnoreCase(mpqPath string) (*os.File, error) {
// First see if file exists with specified case
mpqFile, err := os.Open(mpqPath) //nolint:gosec // Will fix later
if err == nil {
return mpqFile, err
}
if err != nil {
mpqName := filepath.Base(mpqPath)
mpqDir := filepath.Dir(mpqPath)
files, err := ioutil.ReadDir(mpqDir)
var files []fs.FileInfo
files, err = ioutil.ReadDir(mpqDir)
if err != nil {
return nil, err
}
@ -201,4 +201,7 @@ func openIgnoreCase(mpqPath string) (*os.File, error) {
}
return os.Open(filepath.Join(mpqDir, mpqName)) //nolint:gosec // Will fix later
}
return mpqFile, err
}