github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/config/try.go (about) 1 package config 2 3 import ( 4 "errors" 5 6 "github.com/fossas/fossa-cli/files" 7 ) 8 9 var ErrFileNotFound = errors.New("no files existed") 10 11 func TryStrings(candidates ...string) string { 12 for _, c := range candidates { 13 if c != "" { 14 return c 15 } 16 } 17 return "" 18 } 19 20 func TryFiles(candidates ...string) (string, error) { 21 for _, c := range candidates { 22 ok, err := files.Exists(c) 23 if err != nil { 24 return "", err 25 } 26 if ok { 27 return c, nil 28 } 29 } 30 return "", ErrFileNotFound 31 }