blob: 1340e18483b193d9f5001e6709a700e8a8d98f86 [file] [log] [blame]
package cockroachdb
import (
"path/filepath"
"runtime"
"go.skia.org/infra/bazel/go/bazel"
"go.skia.org/infra/go/skerr"
)
// FindCockroach returns the path to the `cockroach` binary downloaded by Bazel.
//
// Calling this function from any Go package will automatically establish a Bazel dependency on the
// corresponding external Bazel repository.
func FindCockroach() (string, error) {
if runtime.GOOS == "linux" {
return filepath.Join(bazel.RunfilesDir(), "external", "cockroachdb_linux", "cockroach"), nil
}
return "", skerr.Fmt("unsupported runtime.GOOS: %q", runtime.GOOS)
}