mirror of
https://github.com/github/codeql.git
synced 2026-01-29 14:23:03 +01:00
Check for nil when getting package info
This commit is contained in:
@@ -148,7 +148,14 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
|
||||
|
||||
for _, pkg := range pkgs {
|
||||
info := pkgInfos[pkg.PkgPath]
|
||||
if info.PkgDir == "" {
|
||||
if info == nil {
|
||||
var err error
|
||||
info, err = util.GetPkgInfo(pkg.PkgPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to get a source directory for input package %s: %s", pkg.PkgPath, err)
|
||||
}
|
||||
}
|
||||
if info == nil || info.PkgDir == "" {
|
||||
log.Fatalf("Unable to get a source directory for input package %s.", pkg.PkgPath)
|
||||
}
|
||||
wantedRoots[info.PkgDir] = true
|
||||
|
||||
@@ -114,6 +114,16 @@ func GetPkgsInfo(patterns []string, includingDeps bool, flags ...string) (map[st
|
||||
return pkgInfoMapping, nil
|
||||
}
|
||||
|
||||
// GetPkgsInfo gets the absolute module and package root directories for the package `pkg`, passing
|
||||
// the internal `go list` command the flags specified by `flags`.
|
||||
func GetPkgInfo(pkg string, flags ...string) (*PkgInfo, error) {
|
||||
pkgInfos, err := GetPkgsInfo([]string{pkg}, false, flags...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pkgInfos[pkg], nil
|
||||
}
|
||||
|
||||
// DepErrors checks there are any errors resolving dependencies for `pkgpath`. It passes the `go
|
||||
// list` command the flags specified by `flags`.
|
||||
func DepErrors(pkgpath string, flags ...string) bool {
|
||||
|
||||
Reference in New Issue
Block a user