Skip to content

proposal: go/types.ImportFunc #63477

Open
@adonovan

Description

@adonovan

I propose to add these two lines to go/types:

// An ImporterFunc is an implementation of the single-method
// types.Importer interface based on a function value.
type ImporterFunc func(path string) (*types.Package, error)

func (f ImporterFunc) Import(path string) (*types.Package, error) { return f(path) }

since we seem to keep typing them out everywhere else:

go/analysis/unitchecker/separate_test.go
293:type importerFunc func(path string) (*types.Package, error)

go/analysis/unitchecker/unitchecker.go
438:type importerFunc func(path string) (*types.Package, error)

go/analysis/passes/cgocall/cgocall.go
367:type importerFunc func(path string) (*types.Package, error)

go/packages/packages.go
1099:type importerFunc func(path string) (*types.Package, error)

gopls/internal/lsp/cache/check.go
1861:type importerFunc func(path string) (*types.Package, error)

internal/gcimporter/iexport_test.go
451:type importerFunc func(path string) (*types.Package, error)

internal/refactor/inline/everything_test.go
233:type importerFunc func(path string) (*types.Package, error)

@gri @findleyr

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions