summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/unrolled/render/fs_embed.go
blob: 5dd2d2ba02125c09da3ec988b79655aa292de00e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// +build go1.16

package render

import (
	"embed"
	"io/fs"
	"path/filepath"
)

// EmbedFileSystem implements FileSystem on top of an embed.FS
type EmbedFileSystem struct {
	embed.FS
}

var _ FileSystem = &EmbedFileSystem{}

func (e *EmbedFileSystem) Walk(root string, walkFn filepath.WalkFunc) error {
	return fs.WalkDir(e.FS, root, func(path string, d fs.DirEntry, _ error) error {
		if d == nil {
			return nil
		}

		info, err := d.Info()
		if err != nil {
			return err
		}

		return walkFn(path, info, err)
	})
}