Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 5198b48

Browse files
committed
Address feedback: naming, wording and comments
1 parent 1853dc3 commit 5198b48

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

internal/gps/pkgtree/pkgtree.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ func fillPackage(p *build.Package) error {
300300
importComments = uniq(importComments)
301301
if len(importComments) > 1 {
302302
return &ConflictingImportComments{
303-
ImportPath: p.ImportPath,
304-
ImportComments: importComments,
303+
ImportPath: p.ImportPath,
304+
ConflictingImportComments: importComments,
305305
}
306306
}
307307
if len(importComments) > 0 {
@@ -360,29 +360,29 @@ func findImportComment(pkgName *ast.Ident, c *ast.CommentGroup) string {
360360
// ConflictingImportComments indicates that the package declares more than one
361361
// different canonical path.
362362
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
365365
}
366366

367367
func (e *ConflictingImportComments) Error() string {
368368
return fmt.Sprintf("import path %s had conflicting import comments: %s",
369-
e.ImportPath, quotedPaths(e.ImportComments))
369+
e.ImportPath, quotedPaths(e.ConflictingImportComments))
370370
}
371371

372372
// NonCanonicalImportRoot reports the situation when the dependee imports a
373373
// package via something other than the package's declared canonical path.
374374
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
377377
}
378378

379379
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",
381381
e.ImportRoot, e.Canonical)
382382
}
383383

384384
func quotedPaths(ps []string) string {
385-
var quoted []string
385+
quoted := make([]string, 0, len(ps))
386386
for _, p := range ps {
387387
quoted = append(quoted, fmt.Sprintf("%q", p))
388388
}

0 commit comments

Comments
 (0)