diff --git a/cmd_build.go b/cmd_build.go index f23df8c..43d3c39 100644 --- a/cmd_build.go +++ b/cmd_build.go @@ -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) } diff --git a/gen.go b/gen.go index 4aac206..78e6235 100644 --- a/gen.go +++ b/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