mirror of
https://github.com/cheat/cheat.git
synced 2024-11-18 01:40:39 +01:00
313b5ebd27
`cheat` now attempts to auto-generate a config file if one cannot be found on the filesystem.
20 lines
378 B
Go
20 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")
|
|
}
|