本文整理汇总了Golang中sourcegraph/com/sourcegraph/srclib/unit.SourceUnit.Dependencies方法的典型用法代码示例。如果您正苦于以下问题:Golang SourceUnit.Dependencies方法的具体用法?Golang SourceUnit.Dependencies怎么用?Golang SourceUnit.Dependencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sourcegraph/com/sourcegraph/srclib/unit.SourceUnit
的用法示例。
在下文中一共展示了SourceUnit.Dependencies方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Scan
// Scan a directory, listing all source units
func Scan(srcdir string, repoURI string, repoSubdir string) ([]*unit.SourceUnit, error) {
if units, isSpecial := specialUnits[repoURI]; isSpecial {
return units, nil
}
p, err := getVENVBinPath()
if err != nil {
return nil, err
}
cmd := exec.Command(filepath.Join(p, "python"), filepath.Join(p, "pydep-run.py"), "list", srcdir)
cmd.Stderr = os.Stderr
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, err
}
if err := cmd.Start(); err != nil {
return nil, err
}
var pkgs []*pkgInfo
if err := json.NewDecoder(stdout).Decode(&pkgs); err != nil {
return nil, err
}
if err := cmd.Wait(); err != nil {
return nil, err
}
// Keep track of all files that have been successfully discovered
discoveredScripts := make(map[string]bool)
units := make([]*unit.SourceUnit, len(pkgs))
for i, pkg := range pkgs {
units[i] = pkg.SourceUnit()
units[i].Files = pythonSourceFiles(pkg.RootDir, discoveredScripts)
units[i].Repo = repoURI // override whatever's in the setup.py file with the actual reposit;5Dory URI
reqs, err := requirements(pkg.RootDir)
if err != nil {
return nil, err
}
reqs_ := make([]interface{}, len(reqs))
for i, req := range reqs {
reqs_[i] = req
}
units[i].Dependencies = reqs_
}
// Scan for independant scripts, appending to the current set of source units
scripts := pythonSourceFiles(srcdir, discoveredScripts)
if len(scripts) > 0 {
scriptsUnit := unit.SourceUnit{
Name: ".",
Type: "PythonProgram",
Files: scripts,
Dir: ".",
Ops: map[string]*srclib.ToolRef{"depresolve": nil, "graph": nil},
}
reqs, err := requirements(srcdir)
if err == nil {
reqs_ := make([]interface{}, len(reqs))
for i, req := range reqs {
reqs_[i] = req
}
scriptsUnit.Dependencies = reqs_
}
units = append(units, &scriptsUnit)
}
return units, nil
}