golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.1k stars 17.68k forks source link

x/tools/gopls: add refactoring capabilities for plumbing context.Context #60081

Open fantapop opened 1 year ago

fantapop commented 1 year ago

Is your feature request related to a problem? Please describe. As we add things like logging and tracing to more places in the codebase, I find I'm often plumbing the context.Context to new areas of the code. It's relatively straightforward but in a large codebase it can take a while.

Describe the solution you'd like It would be great if there was refactor support for plumbing context back upwards through the function stack. I think its fairly standard to have ctx context.Context as the first item in a parameter list. I'd like to be able to put in a nested function call and then right click on the undefined variable error and have an error resolution be "plumb context from parent".

Describe alternatives you've considered The only alternative I've considered is the refactor with some mixture of search/replace and manual fixes . I keep imagining one day I should be able to tell an LLM to do it for me. I searched through the vscode marketplace and didn't see anything that would do what I want.

findleyr commented 1 year ago

This falls into a category of signature refactoring that we'd like to consider adding to gopls. Moving this to the Go issue tracker. CC @adonovan