diff --git a/refactor/rename/mvpkg_test.go b/refactor/rename/mvpkg_test.go index 674fe6cc97..7f5b135381 100644 --- a/refactor/rename/mvpkg_test.go +++ b/refactor/rename/mvpkg_test.go @@ -72,6 +72,14 @@ var _ foo.T "support move destinations whose base names are not valid " + "go identifiers", }, + { + ctxt: fakeContext(map[string][]string{ + "foo": {``}, + "bar": {`package bar`}, + }), + from: "foo", to: "bar", + want: `no initial packages were loaded`, + }, } for _, test := range tests { diff --git a/refactor/rename/rename.go b/refactor/rename/rename.go index 127647bf5d..6d84024bbf 100644 --- a/refactor/rename/rename.go +++ b/refactor/rename/rename.go @@ -392,6 +392,9 @@ func loadProgram(ctxt *build.Context, pkgs map[string]bool) (*loader.Program, er // It would be nice if the loader API permitted "AllowErrors: soft". conf.AllowErrors = true prog, err := conf.Load() + if err != nil { + return nil, err + } var errpkgs []string // Report hard errors in indirectly imported packages. for _, info := range prog.AllPackages { @@ -408,7 +411,7 @@ func loadProgram(ctxt *build.Context, pkgs map[string]bool) (*loader.Program, er return nil, fmt.Errorf("couldn't load packages due to errors: %s%s", strings.Join(errpkgs, ", "), more) } - return prog, err + return prog, nil } func containsHardErrors(errors []error) bool {