Open
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