kataras/iris · error
walk: %s: %w
Error message
walk: %s: %w
What it means
The view helper walk traverses a filesystem (io/fs.FS) with fs.WalkDir; if the walk callback receives a non-nil error for a path (e.g. unreadable directory, invalid root), it wraps it as 'walk: <path>: <err>'. This gives the caller precise context about which path failed during template/asset discovery.
Source
Thrown at view/fs.go:27
)
// walk recursively in "fileSystem" descends "root" path, calling "walkFn".
func walk(fileSystem fs.FS, root string, walkFn filepath.WalkFunc) error {
if root != "" && root != "/" && root != "." {
sub, err := fs.Sub(fileSystem, root)
if err != nil {
return err
}
fileSystem = sub
}
if root == "" {
root = "."
}
return fs.WalkDir(fileSystem, root, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return fmt.Errorf("walk: %s: %w", path, err)
}
info, err := d.Info()
if err != nil {
if err != filepath.SkipDir {
return fmt.Errorf("walk stat: %s: %w", path, err)
}
return nil
}
if info.IsDir() {
return nil
}
walkFnErr := walkFn(path, info, err)
if walkFnErr != nil {
return fmt.Errorf("walk: walkFn: %w", walkFnErr)View on GitHub (pinned to 7bedaf55a0)
Solutions
- Verify the root directory exists and is spelled correctly relative to the FS root ('.' default).
- When using embed.FS, embed the parent directory and strip the prefix (fs.Sub) so paths resolve.
- Ensure the process has read permission on the directory tree.
- Check the wrapped inner error for the OS-level cause (ENOENT, EACCES).
Example fix
// before
view.New(HTML("./viwes", ".html")) // typo
// after
view.New(HTML("./views", ".html")) Defensive patterns
Strategy: validation
Validate before calling
root := "./views"
if info, err := os.Stat(root); err != nil || !info.IsDir() {
return fmt.Errorf("views root %q missing", root)
} Try / catch
if err := view.Register(engines...); err != nil {
var werr *fs.PathError
if errors.As(err, &werr) && strings.HasPrefix(err.Error(), "walk:") {
log.Fatalf("views tree unreadable at %s: %v", werr.Path, werr.Err)
}
return err
} Prevention
- Verify the views directory path at app startup, before registering engines.
- For embed.FS, embed a parent dir and use fs.Sub to strip prefixes so paths resolve.
- Ensure the deployment image actually contains the views directory.
When it happens
Trigger: Calling the walk-based loader (used when registering view engines with a directory or FS) with a root path that doesn't exist in the FS or that cannot be opened, so WalkDir's callback receives err != nil.
Common situations: Typo in the views directory name, embedding views with embed.FS but using the wrong embedded prefix, or a directory removed after build in deployment images.
Related errors
- walk: walkFn: %w
- walk stat: %s: %w
- dest directory: %s: eval symlinks: %w
- unexpected "fsOrDir" argument type of %T (string or fs.FS or
- %s: %w
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/55929454b3213133.
Report an issue: GitHub.