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

  1. Verify the root directory exists and is spelled correctly relative to the FS root ('.' default).
  2. When using embed.FS, embed the parent directory and strip the prefix (fs.Sub) so paths resolve.
  3. Ensure the process has read permission on the directory tree.
  4. 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

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


AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30). Data as JSON: /api/errors/55929454b3213133. Report an issue: GitHub.