1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:44:43 -07:00

internal/imports: pass dummy source for completion functions

The goimports code tries to read source from disk if none is supplied,
but the completion functions don't need source. Pass a dummy slice.

Fixes golang/go#36671.

Change-Id: Ieecc9ee75d39f8f165c7b9764ff49c8334a7fcd2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215681
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Heschi Kreinick 2020-01-21 14:51:24 -05:00
parent 62545537a9
commit d456b1cd8c

View File

@ -119,7 +119,7 @@ func ApplyFixes(fixes []*ImportFix, filename string, src []byte, opt *Options, e
// GetAllCandidates gets all of the packages starting with prefix that can be
// imported by filename, sorted by import path.
func GetAllCandidates(ctx context.Context, callback func(ImportFix), searchPrefix, filename, filePkg string, opt *Options) error {
_, opt, err := initialize(filename, nil, opt)
_, opt, err := initialize(filename, []byte{}, opt)
if err != nil {
return err
}
@ -128,7 +128,7 @@ func GetAllCandidates(ctx context.Context, callback func(ImportFix), searchPrefi
// GetPackageExports returns all known packages with name pkg and their exports.
func GetPackageExports(ctx context.Context, callback func(PackageExport), searchPkg, filename, filePkg string, opt *Options) error {
_, opt, err := initialize(filename, nil, opt)
_, opt, err := initialize(filename, []byte{}, opt)
if err != nil {
return err
}