Source File
util.go
Belonging Package
github.com/carapace-sh/carapace/pkg/util
package util// TODO rename package update/optimize functionsimport ()// FindReverse traverses the filetree upwards to find given file/directory.func ( string, string) ( string, error) {var stringif , = filepath.Abs(); == nil {= + "/" +if _, = os.Stat(); != nil {:= filepath.Dir()if != {return (, )} else {= errors.New("could not find: " + )}}}return}// HasPathPrefix checks if given string has a path prefix.func ( string) bool {return strings.HasPrefix(, ".") ||strings.HasPrefix(, "/") ||strings.HasPrefix(, "~") ||HasVolumePrefix()}// HasVolumePrefix checks if given path has a volume prefix (only for GOOS=windows).func ( string) bool {switch {case runtime.GOOS != "windows":return falsecase len() < 2:return falsecase unicode.IsLetter(rune([0])) && [1] == ':':return truedefault:return false}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |