diff --git a/README.md b/README.md index a440b90..569d07f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ golang-vfstemplate ======================= +Golang library for parsing template files from virtual http filesystem (httpfs) + ## Installation ``` diff --git a/util.go b/util.go index b567151..eb91c6c 100644 --- a/util.go +++ b/util.go @@ -45,3 +45,13 @@ func ReadFileString(fs http.FileSystem, path string) (string, error) { } return string(buf), nil } + +// Exists reports whether the named file or directory exists in http.FileSystem. +func Exists(fs http.FileSystem, name string) bool { + if _, err := Stat(fs, name); err != nil { + if os.IsNotExist(err) { + return false + } + } + return true +}