cheat/internal/config/path.go
Chris Lane 313b5ebd27 feat: config auto-generation
`cheat` now attempts to auto-generate a config file if one cannot be
found on the filesystem.
2020-01-29 14:08:03 -05:00

21 lines
378 B
Go

package config
import (
"fmt"
"os"
)
// Path returns the config file path
func Path(paths []string) (string, error) {
// check if the config file exists on any paths
for _, p := range paths {
if _, err := os.Stat(p); err == nil {
return p, nil
}
}
// we can't find the config file if we make it this far
return "", fmt.Errorf("could not locate config file")
}