2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
- package internal
5
+ package main
6
6
7
7
import (
8
8
"fmt"
9
9
"os"
10
10
"path/filepath"
11
11
"strings"
12
12
13
+ "github.com/golang/dep"
13
14
"github.com/golang/dep/gps/pkgtree"
15
+ "github.com/golang/dep/internal/gps"
14
16
"github.com/pkg/errors"
15
- "github.com/golang/dep"
16
17
)
17
18
18
- // GopathAnalyzer deduces configuration from the projects in the GOPATH
19
- type GopathAnalyzer struct {
19
+ // gopathAnalyzer deduces configuration from the projects in the GOPATH
20
+ type gopathAnalyzer struct {
20
21
Ctx * dep.Ctx
21
22
PkgT pkgtree.PackageTree
22
23
Cpr string
23
24
SM * gps.SourceMgr
24
25
}
25
26
26
- func NewGopathAnalyzer (ctx * dep.Ctx , pkgT pkgtree.PackageTree , cpr string , sm * gps.SourceMgr ) GopathAnalyzer {
27
- return GopathAnalyzer {
27
+ func newGopathAnalyzer (ctx * dep.Ctx , pkgT pkgtree.PackageTree , cpr string , sm * gps.SourceMgr ) gopathAnalyzer {
28
+ return gopathAnalyzer {
28
29
Ctx : ctx ,
29
30
PkgT : pkgtree ,
30
31
Cpr : cpr ,
31
32
SM : sm ,
32
33
}
33
34
}
34
35
35
- func (a GopathAnalyzer ) DeriveRootManifestAndLock (path string , n gps.ProjectRoot ) (gps.RootManifest , gps.Lock , error ) {
36
+ func (a gopathAnalyzer ) DeriveRootManifestAndLock (path string , n gps.ProjectRoot ) (gps.RootManifest , gps.Lock , error ) {
36
37
pd , err := getProjectData (a .Ctx , a .PkgT , a .Cpr , a .SM )
37
38
if err != nil {
38
39
return nil , nil , err
@@ -96,7 +97,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.
96
97
return projectData {}, nil
97
98
}
98
99
99
- Vlogf ("Building dependency graph..." )
100
+ internal . Vlogf ("Building dependency graph..." )
100
101
// Exclude stdlib imports from the list returned from Flatten().
101
102
const omitStdlib = false
102
103
for _ , ip := range rm .Flatten (omitStdlib ) {
@@ -112,21 +113,21 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.
112
113
}
113
114
go syncDep (pr , sm )
114
115
115
- Vlogf ("Found import of %q, analyzing..." , ip )
116
+ internal . Vlogf ("Found import of %q, analyzing..." , ip )
116
117
117
118
dependencies [pr ] = []string {ip }
118
119
v , err := ctx .VersionInWorkspace (pr )
119
120
if err != nil {
120
121
notondisk [pr ] = true
121
- Vlogf ("Could not determine version for %q, omitting from generated manifest" , pr )
122
+ internal . Vlogf ("Could not determine version for %q, omitting from generated manifest" , pr )
122
123
continue
123
124
}
124
125
125
126
ondisk [pr ] = v
126
127
constraints [pr ] = getProjectPropertiesFromVersion (v )
127
128
}
128
129
129
- Vlogf ("Analyzing transitive imports..." )
130
+ internal . Vlogf ("Analyzing transitive imports..." )
130
131
// Explore the packages we've found for transitive deps, either
131
132
// completing the lock or identifying (more) missing projects that we'll
132
133
// need to ask gps to solve for us.
@@ -145,7 +146,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.
145
146
dft = func (pkg string ) error {
146
147
switch colors [pkg ] {
147
148
case white :
148
- Vlogf ("Analyzing %q..." , pkg )
149
+ internal . Vlogf ("Analyzing %q..." , pkg )
149
150
colors [pkg ] = grey
150
151
151
152
pr , err := sm .DeduceProjectRoot (pkg )
@@ -269,7 +270,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.
269
270
}
270
271
271
272
func trimPathPrefix (p1 , p2 string ) string {
272
- if HasFilepathPrefix (p1 , p2 ) {
273
+ if internal . HasFilepathPrefix (p1 , p2 ) {
273
274
return p1 [len (p2 ):]
274
275
}
275
276
return p1
0 commit comments