OXIESEC PANEL
- Current Dir:
/
/
opt
/
golang
/
1.19.4
/
src
/
go
/
ast
Server IP: 2a02:4780:11:1084:0:327f:3464:10
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
12/01/2022 06:13:56 PM
rwxr-xr-x
📄
ast.go
33.67 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
ast_test.go
2.16 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
commentmap.go
8.95 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
commentmap_test.go
3.89 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
example_test.go
5.61 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
filter.go
13.13 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
filter_test.go
1.61 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
import.go
5.67 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
issues_test.go
972 bytes
12/01/2022 06:12:58 PM
rw-r--r--
📄
print.go
5.84 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
print_test.go
1.83 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
resolve.go
5.22 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
scope.go
3.9 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
walk.go
6.43 KB
12/01/2022 06:12:58 PM
rw-r--r--
Editing: filter_test.go
Close
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // To avoid a cyclic dependency with go/parser, this file is in a separate package. package ast_test import ( "bytes" "go/ast" "go/format" "go/parser" "go/token" "testing" ) const input = `package p type t1 struct{} type t2 struct{} func f1() {} func f1() {} func f2() {} func (*t1) f1() {} func (t1) f1() {} func (t1) f2() {} func (t2) f1() {} func (t2) f2() {} func (x *t2) f2() {} ` // Calling ast.MergePackageFiles with ast.FilterFuncDuplicates // keeps a duplicate entry with attached documentation in favor // of one without, and it favors duplicate entries appearing // later in the source over ones appearing earlier. This is why // (*t2).f2 is kept and t2.f2 is eliminated in this test case. const golden = `package p type t1 struct{} type t2 struct{} func f1() {} func f2() {} func (t1) f1() {} func (t1) f2() {} func (t2) f1() {} func (x *t2) f2() {} ` func TestFilterDuplicates(t *testing.T) { // parse input fset := token.NewFileSet() file, err := parser.ParseFile(fset, "", input, 0) if err != nil { t.Fatal(err) } // create package files := map[string]*ast.File{"": file} pkg, err := ast.NewPackage(fset, files, nil, nil) if err != nil { t.Fatal(err) } // filter merged := ast.MergePackageFiles(pkg, ast.FilterFuncDuplicates) // pretty-print var buf bytes.Buffer if err := format.Node(&buf, fset, merged); err != nil { t.Fatal(err) } output := buf.String() if output != golden { t.Errorf("incorrect output:\n%s", output) } }