golang.org/x/tools/gopls@v0.15.3/internal/cmd/usage/fix.hlp (about)

     1  apply suggested fixes
     2  
     3  Usage:
     4    gopls [flags] fix [fix-flags] <filename>
     5  
     6  Example: apply fixes to this file, rewriting it:
     7  
     8  	$ gopls fix -a -w internal/cmd/check.go
     9  
    10  The -a (-all) flag causes all fixes, not just preferred ones, to be
    11  applied, but since no fixes are currently preferred, this flag is
    12  essentially mandatory.
    13  
    14  Arguments after the filename are interpreted as LSP CodeAction kinds
    15  to be applied; the default set is {"quickfix"}, but valid kinds include:
    16  
    17  	quickfix
    18  	refactor
    19  	refactor.extract
    20  	refactor.inline
    21  	refactor.rewrite
    22  	source.organizeImports
    23  	source.fixAll
    24  
    25  CodeAction kinds are hierarchical, so "refactor" includes
    26  "refactor.inline". There is currently no way to enable or even
    27  enumerate all kinds.
    28  
    29  Example: apply any "refactor.rewrite" fixes at the specific byte
    30  offset within this file:
    31  
    32  	$ gopls fix -a internal/cmd/check.go:#43 refactor.rewrite
    33  
    34  fix-flags:
    35    -a,-all
    36      	apply all fixes, not just preferred fixes
    37    -d,-diff
    38      	display diffs instead of edited file content
    39    -l,-list
    40      	display names of edited files
    41    -preserve
    42      	with -write, make copies of original files
    43    -w,-write
    44      	write edited content to source files