styx/utils/files.go

26 lines
471 B
Go
Raw Permalink Normal View History

package utils
import "os"
// FileExists looks for a file, if it doesn't exist, it creates it.
func FileExists(filename string) error {
_, err := os.Stat(filename)
if os.IsNotExist(err) {
_, err := os.Create(filename)
if err != nil {
return err
}
}
return nil
}
// StringInSlice checks for the presence of a string in a slice.
func StringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
}