-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
golang/tools
#478Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.RefactoringIssues related to refactoring toolsIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.
Milestone
Description
gopls version
Irrelevant
go env
Irrelevant
What did you do?
Given the following code:
type Server struct {
api *api.Client
}
func (s *Server) CreateUser(ctx context.Context, userID string) {
err := s.api.CreateUser(ctx, userID)
// ...
}
func (s *Server) DeleteUser(ctx context.Context, userID string) {
err := s.api.DeleteUser(ctx, userID)
// ...
}
What did you see happen?
It would be nice if gopls offered an action to extract an interface out of the used methods on the api field. So for the example given above, it would offer an edit to do something like this:
type Client interface {
CreateUser(context.Context, string) error
DeleteUser(context.Context, string) error
}
type Server struct {
api Client
}
Where the method set of the generated interface is the methods that are called on the field that the action was initiated on, and if there are uses that are not method calls on that field then it would either error or just not offer the action.
What did you expect to see?
Nothing
Editor and settings
No response
Logs
No response
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.RefactoringIssues related to refactoring toolsIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.