@@ -389,7 +389,7 @@ func appendExpandedPackageArg(c *Config, pkgPaths []resolvedPackageArg, p string
389
389
// 5. if there's more than one package in the directory, it returns a MultiplePackageError.
390
390
// 6. if there are no package files in the directory, it just appends the import path as is, leaving it
391
391
// to later logic to produce an error in this case.
392
- func appendExpandedUnqualifiedPackagePath (pkgPaths []resolvedPackageArg , origp string , ip ast.ImportPath , pkgQual string , mainModRoot module.SourceLoc , mainModPath string , tg * tagger ) (_ []resolvedPackageArg , _err error ) {
392
+ func appendExpandedUnqualifiedPackagePath (pkgPaths []resolvedPackageArg , origp string , ip ast.ImportPath , pkgQual string , mainModRoot module.SourceLoc , mainModPath string , tg * tagger ) ([]resolvedPackageArg , error ) {
393
393
ipRel , ok := cutModulePrefix (ip , mainModPath )
394
394
if ! ok {
395
395
// Should never happen.
@@ -410,53 +410,42 @@ func appendExpandedUnqualifiedPackagePath(pkgPaths []resolvedPackageArg, origp s
410
410
// 1. if pkgQual is "*", it appends all the packages present in the package directory.
411
411
if pkgQual == "*" {
412
412
wasAdded := make (map [string ]bool )
413
- iter ( func ( f modimports. ModuleFile , err error ) bool {
413
+ for f , err := range iter {
414
414
if err != nil {
415
- _err = err
416
- return false
415
+ return nil , err
417
416
}
418
417
if err := shouldBuildFile (f .Syntax , tg .tagIsSet ); err != nil {
419
418
// Later build logic should pick up and report the same error.
420
- return true
419
+ continue
421
420
}
422
421
pkgName := f .Syntax .PackageName ()
423
422
if wasAdded [pkgName ] {
424
- return true
423
+ continue
425
424
}
426
425
wasAdded [pkgName ] = true
427
426
ip := ip
428
427
ip .Qualifier = pkgName
429
428
p := ip .String ()
430
429
pkgPaths = append (pkgPaths , resolvedPackageArg {p , p })
431
- return true
432
- })
433
- if _err != nil {
434
- return nil , _err
435
430
}
436
431
return pkgPaths , nil
437
432
}
438
433
var files []modimports.ModuleFile
439
434
foundQualifier := false
440
- // TODO(rog): for f, err := range iter {
441
- iter (func (f modimports.ModuleFile , err error ) bool {
435
+ for f , err := range iter {
442
436
if err != nil {
443
- _err = err
444
- return false
437
+ return nil , err
445
438
}
446
439
pkgName := f .Syntax .PackageName ()
447
440
// 2. if pkgQual is "_", it looks for a package file with no package name.
448
441
// 3. if there's a package named after ip.Qualifier it chooses that
449
442
if (pkgName != "" && pkgName == ip .Qualifier ) || (pkgQual == "_" && pkgName == "" ) {
450
443
foundQualifier = true
451
- return false
444
+ break
452
445
}
453
446
if pkgName != "" {
454
447
files = append (files , f )
455
448
}
456
- return true
457
- })
458
- if _err != nil {
459
- return nil , _err
460
449
}
461
450
if foundQualifier {
462
451
// We found the actual package that was implied by the import path (or pkgQual == "_").
0 commit comments