mirror of https://github.com/go-python/gopy.git
a couple of fixes to prevent crashing if package has no files (e.g., go.mod not set properly)
This commit is contained in:
parent
5b7e6c3b07
commit
9b66a3f22d
|
@ -74,12 +74,12 @@ func gopyRunCmdBuild(cmdr *commander.Command, args []string) error {
|
|||
return fmt.Errorf("gopy-gen: go build / load of package failed with path=%q: %v", path, err)
|
||||
}
|
||||
pkg, err := parsePackage(bpkg)
|
||||
if cfg.Name == "" {
|
||||
cfg.Name = pkg.Name()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cfg.Name == "" {
|
||||
cfg.Name = pkg.Name()
|
||||
}
|
||||
}
|
||||
return runBuild("build", cfg)
|
||||
}
|
||||
|
|
5
gen.go
5
gen.go
|
@ -122,6 +122,11 @@ func loadPackage(path string, buildFirst bool) (*packages.Package, error) {
|
|||
}
|
||||
|
||||
func parsePackage(bpkg *packages.Package) (*bind.Package, error) {
|
||||
if len(bpkg.GoFiles) == 0 {
|
||||
err := fmt.Errorf("gopy: no files in package %q", bpkg.PkgPath)
|
||||
fmt.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
dir, _ := filepath.Split(bpkg.GoFiles[0])
|
||||
p := bpkg.Types
|
||||
|
||||
|
|
Loading…
Reference in New Issue