Merge pull request #114447 from yulng/elseyw

fix:Optimize code for else logic
This commit is contained in:
Kubernetes Prow Robot 2023-02-16 08:33:40 -08:00 committed by GitHub
commit d004f324d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,14 +207,14 @@ func loadProfiles(path string) error {
// If the given fileinfo is a symlink, return the FileInfo of the target. Otherwise, return the
// given fileinfo.
func resolveSymlink(basePath string, entry os.DirEntry) (os.FileInfo, error) {
if info, err := entry.Info(); err != nil {
info, err := entry.Info()
if err != nil {
return nil, fmt.Errorf("error getting the fileInfo: %v", err)
} else {
}
if info.Mode()&os.ModeSymlink == 0 {
// Not a symlink.
return info, nil
}
}
fpath := filepath.Join(basePath, entry.Name())
resolvedName, err := filepath.EvalSymlinks(fpath)