@@ -419,10 +419,13 @@ func ImportPathToFullPrefix(path string) string { // Use all other import paths directly as prefix. return path + ": " case strings.HasPrefix(path, "golang.org/x/") || path == "golang.org/x": // Map "golang.org/x/..." to "x/...". return path[len("golang.org/"):] + ": " case strings.HasPrefix(path, "golang.org/dl/") || path == "golang.org/dl": // Map "golang.org/dl/..." to "dl/...". return path[len("golang.org/"):] + ": " case path == otherPackages: // Empty prefix for otherPackages. return "" } } @@ -436,13 +439,17 @@ func ImportPathsToFullPrefix(paths []string) string { var b strings.Builder for i, p := range paths { if i != 0 { b.WriteString(", ") } if strings.HasPrefix(p, "golang.org/x/") || p == "golang.org/x" { switch { case strings.HasPrefix(p, "golang.org/x/") || p == "golang.org/x": // Map "golang.org/x/..." to "x/...". p = p[len("golang.org/"):] case strings.HasPrefix(p, "golang.org/dl/") || p == "golang.org/dl": // Map "golang.org/dl/..." to "dl/...". p = p[len("golang.org/"):] } b.WriteString(p) } b.WriteString(": ") return b.String()
@@ -21,10 +21,18 @@ func TestImportPathToFullPrefix(t *testing.T) { }, { in: "golang.org/x", want: "x: ", }, { in: "golang.org/dl/go1.2.3", want: "dl/go1.2.3: ", }, { in: "golang.org/dl", want: "dl: ", }, { in: "other", want: "", }, }