OXIESEC PANEL
- Current Dir:
/
/
opt
/
golang
/
1.19.4
/
src
/
go
/
doc
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
📄
Makefile
246 bytes
12/01/2022 06:12:58 PM
rw-r--r--
📁
comment
-
12/01/2022 06:13:56 PM
rwxr-xr-x
📄
comment.go
1.93 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
comment_test.go
2.7 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
doc.go
11.08 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
doc_test.go
6.66 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
example.go
21.34 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
example_internal_test.go
1.64 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
example_test.go
9.62 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
exports.go
8.5 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
filter.go
2.22 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
headscan.go
2.49 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
reader.go
28.04 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
synopsis.go
2.19 KB
12/01/2022 06:12:58 PM
rw-r--r--
📄
synopsis_test.go
1.81 KB
12/01/2022 06:12:58 PM
rw-r--r--
📁
testdata
-
12/01/2022 06:13:56 PM
rwxr-xr-x
Editing: example_internal_test.go
Close
// Copyright 2022 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. package doc import ( "go/parser" "go/token" "reflect" "strconv" "strings" "testing" ) func TestImportGroupStarts(t *testing.T) { for _, test := range []struct { name string in string want []string // paths of group-starting imports }{ { name: "one group", in: `package p import ( "a" "b" "c" "d" ) `, want: []string{"a"}, }, { name: "several groups", in: `package p import ( "a" "b" "c" "d" ) `, want: []string{"a", "b", "d"}, }, { name: "extra space", in: `package p import ( "a" "b" "c" "d" ) `, want: []string{"a", "b", "d"}, }, { name: "line comment", in: `package p import ( "a" // comment "b" // comment "c" )`, want: []string{"a", "c"}, }, { name: "named import", in: `package p import ( "a" n "b" m "c" "d" )`, want: []string{"a", "c"}, }, { name: "blank import", in: `package p import ( "a" _ "b" _ "c" "d" )`, want: []string{"a", "b", "c"}, }, } { t.Run(test.name, func(t *testing.T) { fset := token.NewFileSet() file, err := parser.ParseFile(fset, "test.go", strings.NewReader(test.in), parser.ParseComments) if err != nil { t.Fatal(err) } imps := findImportGroupStarts1(file.Imports) got := make([]string, len(imps)) for i, imp := range imps { got[i], err = strconv.Unquote(imp.Path.Value) if err != nil { t.Fatal(err) } } if !reflect.DeepEqual(got, test.want) { t.Errorf("got %v, want %v", got, test.want) } }) } }