Skip to content

Commit

Permalink
Added "Exists" function
Browse files Browse the repository at this point in the history
  • Loading branch information
shakahl committed May 26, 2019
1 parent 3004c1b commit 1bf6415
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
golang-vfstemplate
=======================

Golang library for parsing template files from virtual http filesystem (httpfs)

## Installation

```
Expand Down
10 changes: 10 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 1bf6415

Please sign in to comment.