diff --git a/internal/gopathAnalyzer.go b/cmd/dep/gopathAnalyzer.go similarity index 92% rename from internal/gopathAnalyzer.go rename to cmd/dep/gopathAnalyzer.go index 281da17775..12703beebc 100644 --- a/internal/gopathAnalyzer.go +++ b/cmd/dep/gopathAnalyzer.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package internal +package main import ( "fmt" @@ -10,21 +10,22 @@ import ( "path/filepath" "strings" + "github.com/golang/dep" "github.com/golang/dep/gps/pkgtree" + "github.com/golang/dep/internal/gps" "github.com/pkg/errors" - "github.com/golang/dep" ) -// GopathAnalyzer deduces configuration from the projects in the GOPATH -type GopathAnalyzer struct { +// gopathAnalyzer deduces configuration from the projects in the GOPATH +type gopathAnalyzer struct { Ctx *dep.Ctx PkgT pkgtree.PackageTree Cpr string SM *gps.SourceMgr } -func NewGopathAnalyzer(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.SourceMgr) GopathAnalyzer { - return GopathAnalyzer{ +func newGopathAnalyzer(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.SourceMgr) gopathAnalyzer { + return gopathAnalyzer{ Ctx: ctx, PkgT: pkgtree, Cpr: cpr, @@ -32,7 +33,7 @@ func NewGopathAnalyzer(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *g } } -func (a GopathAnalyzer) DeriveRootManifestAndLock(path string, n gps.ProjectRoot) (gps.RootManifest, gps.Lock, error) { +func (a gopathAnalyzer) DeriveRootManifestAndLock(path string, n gps.ProjectRoot) (gps.RootManifest, gps.Lock, error) { pd, err := getProjectData(a.Ctx, a.PkgT, a.Cpr, a.SM) if err != nil { return nil, nil, err @@ -96,7 +97,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps. return projectData{}, nil } - Vlogf("Building dependency graph...") + internal.Vlogf("Building dependency graph...") // Exclude stdlib imports from the list returned from Flatten(). const omitStdlib = false for _, ip := range rm.Flatten(omitStdlib) { @@ -112,13 +113,13 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps. } go syncDep(pr, sm) - Vlogf("Found import of %q, analyzing...", ip) + internal.Vlogf("Found import of %q, analyzing...", ip) dependencies[pr] = []string{ip} v, err := ctx.VersionInWorkspace(pr) if err != nil { notondisk[pr] = true - Vlogf("Could not determine version for %q, omitting from generated manifest", pr) + internal.Vlogf("Could not determine version for %q, omitting from generated manifest", pr) continue } @@ -126,7 +127,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps. constraints[pr] = getProjectPropertiesFromVersion(v) } - Vlogf("Analyzing transitive imports...") + internal.Vlogf("Analyzing transitive imports...") // Explore the packages we've found for transitive deps, either // completing the lock or identifying (more) missing projects that we'll // need to ask gps to solve for us. @@ -145,7 +146,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps. dft = func(pkg string) error { switch colors[pkg] { case white: - Vlogf("Analyzing %q...", pkg) + internal.Vlogf("Analyzing %q...", pkg) colors[pkg] = grey pr, err := sm.DeduceProjectRoot(pkg) @@ -269,7 +270,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps. } func trimPathPrefix(p1, p2 string) string { - if HasFilepathPrefix(p1, p2) { + if internal.HasFilepathPrefix(p1, p2) { return p1[len(p2):] } return p1 diff --git a/cmd/dep/init.go b/cmd/dep/init.go index 1e996497bd..c4ece2f24c 100644 --- a/cmd/dep/init.go +++ b/cmd/dep/init.go @@ -113,12 +113,12 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, loggers *Loggers, args []string) error var rootAnalyzer internal.RootProjectAnalyzer var analyzer gps.ProjectAnalyzer if cmd.skipTools { - rootAnalyzer = internal.NewGopathAnalyzer(ctx, pkgtree, cpr, sm) + rootAnalyzer = newGopathAnalyzer(ctx, pkgtree, cpr, sm) analyzer = dep.Analyzer{} } else { rootAnalyzer = internal.CompositeAnalyzer{ Analyzers: []internal.RootProjectAnalyzer{ - internal.NewGopathAnalyzer(ctx, pkgtree, cpr, sm), + newGopathAnalyzer(ctx, pkgtree, cpr, sm), internal.ImportAnalyzer{}, }} analyzer = internal.ImportAnalyzer{}