Skip to content

Commit

Permalink
Fixing govet -shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasmannem committed Feb 21, 2022
1 parent 10324de commit 17cdf61
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/postgresql/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"io/ioutil"
"os"
"os/exec"
Expand Down Expand Up @@ -331,7 +332,8 @@ func (p *Manager) moveWal() (err error) {
return err
}
log.Debugf("moving WAL files from %s to %s", curPath, tmpPath)
if entries, err := ioutil.ReadDir(curPath); err != nil {
var entries []fs.FileInfo
if entries, err = ioutil.ReadDir(curPath); err != nil {
log.Errorf("could not read contents of folder %s: %e", curPath, err)
return err
} else {
Expand All @@ -346,7 +348,8 @@ func (p *Manager) moveWal() (err error) {
}
}

if symlinkStat, err := os.Lstat(symlinkPath); err != nil {
var symlinkStat fs.FileInfo
if symlinkStat, err = os.Lstat(symlinkPath); err != nil {
log.Errorf("could not get info on current pg_wal folder/symlink %s: %e", symlinkPath, err)
return err
} else if symlinkStat.Mode()&os.ModeSymlink != 0 {
Expand All @@ -355,12 +358,12 @@ func (p *Manager) moveWal() (err error) {
return err
}
} else if symlinkStat.IsDir() {
if err := syscall.Rmdir(symlinkPath); err != nil {
if err = syscall.Rmdir(symlinkPath); err != nil {
log.Errorf("could not remove current folder %s: %e", symlinkPath, err)
return err
}
} else {
err := fmt.Errorf("location %s is no symlink and no dir, so please check and resolve by hand", symlinkPath)
err = fmt.Errorf("location %s is no symlink and no dir, so please check and resolve by hand", symlinkPath)
log.Error(err)
return err
}
Expand Down

0 comments on commit 17cdf61

Please sign in to comment.