golang.org/x/tools/gopls@v0.15.3/internal/test/marker/testdata/codeaction/functionextraction_issue44813.txt (about)

     1  This test verifies the fix for golang/go#44813: extraction failure when there
     2  are blank identifiers.
     3  
     4  -- go.mod --
     5  module mod.test/extract
     6  
     7  go 1.18
     8  
     9  -- p.go --
    10  package extract
    11  
    12  import "fmt"
    13  
    14  func main() {
    15  	x := []rune{} //@codeaction("x", end, "refactor.extract", ext)
    16  	s := "HELLO"
    17  	for _, c := range s {
    18  		x = append(x, c)
    19  	} //@loc(end, "}")
    20  	fmt.Printf("%x\n", x)
    21  }
    22  
    23  -- @ext/p.go --
    24  package extract
    25  
    26  import "fmt"
    27  
    28  func main() {
    29  	//@codeaction("x", end, "refactor.extract", ext)
    30  	x := newFunction() //@loc(end, "}")
    31  	fmt.Printf("%x\n", x)
    32  }
    33  
    34  func newFunction() []rune {
    35  	x := []rune{}
    36  	s := "HELLO"
    37  	for _, c := range s {
    38  		x = append(x, c)
    39  	}
    40  	return x
    41  }
    42