2020-01-22 15:49:52 +01:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import "os"
|
|
|
|
|
2020-02-14 11:36:47 +01:00
|
|
|
// FileExists looks for a file, if it doesn't exist, it creates it.
|
2020-01-22 15:49:52 +01:00
|
|
|
func FileExists(filename string) error {
|
|
|
|
_, err := os.Stat(filename)
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
_, err := os.Create(filename)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2020-05-29 11:32:55 +02:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|