func walk(filename string, linkDirname string, walkFn filepath.WalkFunc) error {
	symWalkFunc := func(path string, info os.FileInfo, err error) error {

		if fname, err := filepath.Rel(filename, path); err == nil {
			path = filepath.Join(linkDirname, fname)
		} else {
			return err
		}

		if err == nil && info.Mode()&os.ModeSymlink == os.ModeSymlink {
			finalPath, err := filepath.EvalSymlinks(path)
			if err != nil {
				// don't bail out if symlink is invalid
				return walkFn(path, info, err)
			}
			info, err := os.Lstat(finalPath)
			if err != nil {
				return walkFn(path, info, err)
			}
			if info.IsDir() {
				return walk(finalPath, path, walkFn)
			}
		}

		return walkFn(path, info, err)
	}
	return filepath.Walk(filename, symWalkFunc)
}
// symwalkFunc calls the provided WalkFn for regular files.
// However, when it encounters a symbolic link, it resolves the link fully using the
// filepath.EvalSymlinks function and recursively calls symwalk.Walk on the resolved path.
// This ensures that unlink filepath.Walk, traversal does not stop at symbolic links.
//
// Note that symwalk.Walk does not terminate if there are any non-terminating loops in
// the file structure.
symwalkFunc calls the provided WalkFn for regular files.
However, when it encounters a symbolic link, it resolves the link fully using the
filepath.EvalSymlinks function and recursively calls symwalk.Walk on the resolved path.
This ensures that unlink filepath.Walk, traversal does not stop at symbolic links.

Note that symwalk.Walk does not terminate if there are any non-terminating loops in
the file structure.
// symwalkFunc calls the provided WalkFn for regular files . // However when it encounters a symbolic link it resolves the link fully using the // filepath . EvalSymlinks function and recursively calls symwalk . Walk on the resolved path . // This ensures that unlink filepath . Walk traversal does not stop at symbolic links . // // Note that symwalk . Walk does not terminate if there are any non - terminating loops in // the file structure .
func walk(filename string, linkDirname string, walkFn filepath.WalkFunc) error {
	symWalkFunc := func(path string, info os.FileInfo, err error) error {
		if fname, err := filepath.Rel(filename, path); err == nil {
			path = filepath.Join(linkDirname, fname)
		} else {
			return err
		}
		if err == nil && info.Mode()&os.ModeSymlink == os.ModeSymlink {
			finalPath, err := filepath.EvalSymlinks(path)
			if err != nil {
				return walkFn(path, info, err)
			}
			info, err := os.Lstat(finalPath)
			if err != nil {
				return walkFn(path, info, err)
			}
			if info.IsDir() {
				return walk(finalPath, path, walkFn)
			}
		}
		return walkFn(path, info, err)
	}
	return filepath.Walk(filename, symWalkFunc)
}
func walk ( filename string , linkDirname string , walkFn filepath . WalkFunc ) error { symWalkFunc := func ( path string , info os . FileInfo , err error ) error { if fname , err := filepath . Rel ( filename , path ) ; err == nil { path = filepath . Join ( linkDirname , fname ) } else { return err } if err == nil && info . Mode ( ) & os . ModeSymlink == os . ModeSymlink { finalPath , err := filepath . EvalSymlinks ( path ) if err != nil { return walkFn ( path , info , err ) } info , err := os . Lstat ( finalPath ) if err != nil { return walkFn ( path , info , err ) } if info . IsDir ( ) { return walk ( finalPath , path , walkFn ) } } return walkFn ( path , info , err ) } return filepath . Walk ( filename , symWalkFunc ) }
symwalkFunc calls the provided WalkFn for regular files.
symwalkFunc calls the provided WalkFn for regular files .
// don't bail out if symlink is invalid