@@ -760,23 +760,22 @@ type ParsedPackage struct {
760
760
// The given skip paths will not be returned in the results.
761
761
// This will not return any `*_test` packages in the results.
762
762
func (p * ParsedPackage ) Imports (skip ... string ) []string {
763
- importMap := make (map [string ]struct {})
763
+ seen := make (map [string ]struct {})
764
+ for _ , s := range skip {
765
+ seen [s ] = struct {}{}
766
+ }
767
+ imports := []string {}
764
768
for _ , file := range p .GoFiles {
765
769
for _ , imp := range file .Imports {
766
770
path := strings .Trim (imp .Path .Value , `"` )
767
- if ! strings .HasSuffix (path , "_test" ) {
768
- importMap [path ] = struct {}{}
771
+ if _ , ok := seen [path ]; ! ok {
772
+ if ! strings .HasSuffix (path , "_test" ) {
773
+ imports = append (imports , path )
774
+ }
775
+ seen [path ] = struct {}{}
769
776
}
770
777
}
771
778
}
772
- for _ , skip := range skip {
773
- delete (importMap , skip )
774
- }
775
-
776
- imports := make ([]string , 0 , len (importMap ))
777
- for imp := range importMap {
778
- imports = append (imports , imp )
779
- }
780
779
sort .Strings (imports )
781
780
return imports
782
781
}
0 commit comments