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