Skip to content

x/tools/gopls: extract func/method arg(s) to struct #65552

@danp

Description

@danp

Given something like this, where timeout is an option:

func search(query string, timeout time.Duration) {}

When it's time to add another option, one might extract timeout to an options struct so it's then easy to add more things:

type searchOptions struct {
  timeout time.Duration
}

func search(query string, opts searchOptions) {}

A code action for this kind of extraction would be very helpful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.RefactoringIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.help wanted

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions