/usr/share/gocode/src/github.com/constabulary/gb/cmd/path.go is in golang-github-constabulary-gb-dev 0.4.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | package cmd
import (
"fmt"
"os"
"path/filepath"
"github.com/pkg/errors"
)
// FindProjectroot works upwards from path seaching for the
// src/ directory which identifies the project root.
func FindProjectroot(path string) (string, error) {
if path == "" {
return "", errors.New("project root is blank")
}
start := path
for path != filepath.Dir(path) {
root := filepath.Join(path, "src")
if _, err := os.Stat(root); err != nil {
if os.IsNotExist(err) {
path = filepath.Dir(path)
continue
}
return "", err
}
return path, nil
}
return "", fmt.Errorf(`could not find project root in "%s" or its parents`, start)
}
|