@@ -300,8 +300,8 @@ func fillPackage(p *build.Package) error {
300
300
importComments = uniq (importComments )
301
301
if len (importComments ) > 1 {
302
302
return & ConflictingImportComments {
303
- ImportPath : p .ImportPath ,
304
- ImportComments : importComments ,
303
+ ImportPath : p .ImportPath ,
304
+ ConflictingImportComments : importComments ,
305
305
}
306
306
}
307
307
if len (importComments ) > 0 {
@@ -360,29 +360,29 @@ func findImportComment(pkgName *ast.Ident, c *ast.CommentGroup) string {
360
360
// ConflictingImportComments indicates that the package declares more than one
361
361
// different canonical path.
362
362
type ConflictingImportComments struct {
363
- ImportPath string
364
- ImportComments []string
363
+ ImportPath string // An import path refering to this package
364
+ ConflictingImportComments []string // All distinct "canonical" paths encountered in the package files
365
365
}
366
366
367
367
func (e * ConflictingImportComments ) Error () string {
368
368
return fmt .Sprintf ("import path %s had conflicting import comments: %s" ,
369
- e .ImportPath , quotedPaths (e .ImportComments ))
369
+ e .ImportPath , quotedPaths (e .ConflictingImportComments ))
370
370
}
371
371
372
372
// NonCanonicalImportRoot reports the situation when the dependee imports a
373
373
// package via something other than the package's declared canonical path.
374
374
type NonCanonicalImportRoot struct {
375
- ImportRoot string
376
- Canonical string
375
+ ImportRoot string // A root path that is being used to import a package
376
+ Canonical string // A canonical path declared by the package being imported
377
377
}
378
378
379
379
func (e * NonCanonicalImportRoot ) Error () string {
380
- return fmt .Sprintf ("importing via path %q, but package insists on a canonical path %q" ,
380
+ return fmt .Sprintf ("import root %q is not a prefix for the package's declared canonical path %q" ,
381
381
e .ImportRoot , e .Canonical )
382
382
}
383
383
384
384
func quotedPaths (ps []string ) string {
385
- var quoted []string
385
+ quoted := make ( []string , 0 , len ( ps ))
386
386
for _ , p := range ps {
387
387
quoted = append (quoted , fmt .Sprintf ("%q" , p ))
388
388
}
0 commit comments