| |
| -- go.mod -- |
| module example.com |
| go 1.18 |
| |
| -- template/template.go -- |
| package template |
| |
| import ( |
| "go/ast" // defines many unencapsulated structs |
| "go/token" |
| ) |
| |
| func before(from, to token.Pos) ast.BadExpr { return ast.BadExpr{From: from, To: to} } |
| func after(from, to token.Pos) ast.BadExpr { return ast.BadExpr{from, to} } |
| |
| -- in/g1/g1.go -- |
| package g1 |
| |
| import "go/ast" |
| |
| func example() { |
| _ = ast.BadExpr{From: 123, To: 456} // match |
| _ = ast.BadExpr{123, 456} // no match |
| _ = ast.BadExpr{From: 123} // no match |
| _ = ast.BadExpr{To: 456} // no match |
| } |
| |
| -- out/g1/g1.go -- |
| package g1 |
| |
| import "go/ast" |
| |
| func example() { |
| _ = ast.BadExpr{123, 456} // match |
| _ = ast.BadExpr{123, 456} // no match |
| _ = ast.BadExpr{From: 123} // no match |
| _ = ast.BadExpr{To: 456} // no match |
| } |