golang/go

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

Open

#65,552 opened on Feb 6, 2024

View on GitHub
 (5 comments) (6 reactions) (0 assignees)Go (19,008 forks)batch import
FeatureRequestRefactoringToolsgoplshelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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!

Contributor guide