PkSourceRoot returns the root of the source tree, or an error.
()
| 353 | |
| 354 | // PkSourceRoot returns the root of the source tree, or an error. |
| 355 | func PkSourceRoot() (string, error) { |
| 356 | root, err := GoModPackagePath() |
| 357 | if err == nil { |
| 358 | return root, nil |
| 359 | } |
| 360 | err = fmt.Errorf("could not found go.mod, trying GOPATH: %w", err) |
| 361 | root, errp := GoPackagePath("perkeep.org") |
| 362 | if errors.Is(errp, os.ErrNotExist) { |
| 363 | return "", fmt.Errorf("directory \"perkeep.org\" not found under GOPATH/src; "+ |
| 364 | "can't run Perkeep integration tests: %v", errors.Join(err, errp)) |
| 365 | } |
| 366 | return root, nil |
| 367 | } |
| 368 | |
| 369 | // GoPackagePath returns the path to the provided Go package's |
| 370 | // source directory. |