mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-01-15 13:56:58 -05:00
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:
parent
ecab467a0f
commit
4558da0136
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -181,14 +182,13 @@ func (mpq *MPQ) Size() uint32 {
|
|||||||
func openIgnoreCase(mpqPath string) (*os.File, error) {
|
func openIgnoreCase(mpqPath string) (*os.File, error) {
|
||||||
// First see if file exists with specified case
|
// First see if file exists with specified case
|
||||||
mpqFile, err := os.Open(mpqPath) //nolint:gosec // Will fix later
|
mpqFile, err := os.Open(mpqPath) //nolint:gosec // Will fix later
|
||||||
if err == nil {
|
if err != nil {
|
||||||
return mpqFile, err
|
|
||||||
}
|
|
||||||
|
|
||||||
mpqName := filepath.Base(mpqPath)
|
mpqName := filepath.Base(mpqPath)
|
||||||
mpqDir := filepath.Dir(mpqPath)
|
mpqDir := filepath.Dir(mpqPath)
|
||||||
|
|
||||||
files, err := ioutil.ReadDir(mpqDir)
|
var files []fs.FileInfo
|
||||||
|
files, err = ioutil.ReadDir(mpqDir)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 os.Open(filepath.Join(mpqDir, mpqName)) //nolint:gosec // Will fix later
|
||||||
|
}
|
||||||
|
|
||||||
|
return mpqFile, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user