| 1 |
|
| 2 |
-- go.mod -- |
| 3 |
module example.com |
| 4 |
go 1.18 |
| 5 |
|
| 6 |
-- template/template.go -- |
| 7 |
package template |
| 8 |
|
| 9 |
import ( |
| 10 |
"go/ast" // defines many unencapsulated structs |
| 11 |
"go/token" |
| 12 |
) |
| 13 |
|
| 14 |
func before(from, to token.Pos) ast.BadExpr { return ast.BadExpr{from, to} } |
| 15 |
func after(from, to token.Pos) ast.BadExpr { return ast.BadExpr{From: from, To: to} } |
| 16 |
|
| 17 |
-- in/h1/h1.go -- |
| 18 |
package h1 |
| 19 |
|
| 20 |
import "go/ast" |
| 21 |
|
| 22 |
func example() { |
| 23 |
_ = ast.BadExpr{From: 123, To: 456} // no match |
| 24 |
_ = ast.BadExpr{123, 456} // match |
| 25 |
_ = ast.BadExpr{From: 123} // no match |
| 26 |
_ = ast.BadExpr{To: 456} // no match |
| 27 |
} |
| 28 |
|
| 29 |
-- out/h1/h1.go -- |
| 30 |
package h1 |
| 31 |
|
| 32 |
import "go/ast" |
| 33 |
|
| 34 |
func example() { |
| 35 |
_ = ast.BadExpr{From: 123, To: 456} // no match |
| 36 |
_ = ast.BadExpr{From: 123, To: 456} // match |
| 37 |
_ = ast.BadExpr{From: 123} // no match |
| 38 |
_ = ast.BadExpr{To: 456} // no match |
| 39 |
} |