golang.org/x/tools/gopls@v0.15.3/internal/cmd/usage/codelens.hlp (about) 1 List or execute code lenses for a file 2 3 Usage: 4 gopls [flags] codelens [codelens-flags] file[:line[:col]] [title] 5 6 The codelens command lists or executes code lenses for the specified 7 file, or line within a file. A code lens is a command associated with 8 a position in the code. 9 10 With an optional title argment, only code lenses matching that 11 title are considered. 12 13 By default, the codelens command lists the available lenses for the 14 specified file or line within a file, including the title and 15 title of the command. With the -exec flag, the first matching command 16 is executed, and its output is printed to stdout. 17 18 Example: 19 20 $ gopls codelens a_test.go # list code lenses in a file 21 $ gopls codelens a_test.go:10 # list code lenses on line 10 22 $ gopls codelens a_test.go gopls.test # list gopls.test commands 23 $ gopls codelens -run a_test.go:10 gopls.test # run a specific test 24 25 codelens-flags: 26 -d,-diff 27 display diffs instead of edited file content 28 -exec 29 execute the first matching code lens 30 -l,-list 31 display names of edited files 32 -preserve 33 with -write, make copies of original files 34 -w,-write 35 write edited content to source files