golang.org/x/tools@v0.21.0/internal/refactor/inline/testdata/comments.txtar (about)

     1  Test of (lack of) comment preservation by inlining,
     2  whether by literalization or reduction.
     3  
     4  Comment handling was better in an earlier implementation
     5  based on byte-oriented file surgery; switching to AST
     6  manipulation (though better in all other respects) was
     7  a regression. The underlying problem of AST comment fidelity
     8  is Go issue #20744.
     9  
    10  -- go.mod --
    11  module testdata
    12  go 1.12
    13  
    14  -- a/f.go --
    15  package a
    16  
    17  func _() {
    18  	f() //@ inline(re"f", f)
    19  }
    20  
    21  func f() {
    22  	// a
    23  	/* b */ g() /* c */
    24  	// d
    25  }
    26  
    27  -- f --
    28  package a
    29  
    30  func _() {
    31  	g() //@ inline(re"f", f)
    32  }
    33  
    34  func f() {
    35  	// a
    36  	/* b */
    37  	g() /* c */
    38  	// d
    39  }
    40  
    41  -- a/g.go --
    42  package a
    43  
    44  func _() {
    45  	println(g()) //@ inline(re"g", g)
    46  }
    47  
    48  func g() int { return 1 /*hello*/ + /*there*/ 1 }
    49  
    50  -- g --
    51  package a
    52  
    53  func _() {
    54  	println(1 + 1) //@ inline(re"g", g)
    55  }
    56  
    57  func g() int { return 1 /*hello*/ + /*there*/ 1 }