You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
packer/vendor/github.com/approvals/go-approval-tests/utils/file_utils.go

25 lines
407 B

package utils
import (
"io/ioutil"
"os"
)
// DoesFileExist checks if a file exists.
func DoesFileExist(fileName string) bool {
_, err := os.Stat(fileName)
if os.IsNotExist(err) {
return false
}
return true
}
// EnsureExists creates if the file does not already exist.
func EnsureExists(fileName string) {
if DoesFileExist(fileName) {
return
}
ioutil.WriteFile(fileName, []byte(""), 0644)
}