@@ -30,14 +30,19 @@ disable this behavior. The following external tools are supported: glide.
30
30
Any dependencies that are not constrained by external configuration use the
31
31
GOPATH analysis below.
32
32
33
- The version of each dependency will reflect the current state of the GOPATH. If
34
- a dependency doesn't exist in the GOPATH, a version will be selected from the
35
- versions available from the upstream source per the following algorithm:
33
+ By default, the dependencies are resolved over the network. A version will be
34
+ selected from the versions available from the upstream source per the following
35
+ algorithm:
36
36
37
37
- Tags conforming to semver (sorted by semver rules)
38
38
- Default branch(es) (sorted lexicographically)
39
39
- Non-semver tags (sorted lexicographically)
40
40
41
+ An alternate mode can be activated by passing -gopath. In this mode, the version
42
+ of each dependency will reflect the current state of the GOPATH. If a dependency
43
+ doesn't exist in the GOPATH, a version will be selected based on the above
44
+ network version selection algorithm.
45
+
41
46
A Gopkg.toml file will be written with inferred version constraints for all
42
47
direct dependencies. Gopkg.lock will be written with precise versions, and
43
48
vendor/ will be populated with the precise versions written to Gopkg.lock.
@@ -52,11 +57,13 @@ func (cmd *initCommand) Hidden() bool { return false }
52
57
func (cmd * initCommand ) Register (fs * flag.FlagSet ) {
53
58
fs .BoolVar (& cmd .noExamples , "no-examples" , false , "don't include example in Gopkg.toml" )
54
59
fs .BoolVar (& cmd .skipTools , "skip-tools" , false , "skip importing configuration from other dependency managers" )
60
+ fs .BoolVar (& cmd .gopath , "gopath" , false , "search in GOPATH for dependencies" )
55
61
}
56
62
57
63
type initCommand struct {
58
64
noExamples bool
59
65
skipTools bool
66
+ gopath bool
60
67
}
61
68
62
69
func (cmd * initCommand ) Run (ctx * dep.Ctx , args []string ) error {
@@ -132,13 +139,17 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
132
139
if err != nil {
133
140
return err
134
141
}
135
- gs := newGopathScanner (ctx , directDeps , sm )
136
- err = gs .InitializeRootManifestAndLock (p .Manifest , p .Lock )
137
- if err != nil {
138
- return err
142
+
143
+ if cmd .gopath {
144
+ gs := newGopathScanner (ctx , directDeps , sm )
145
+ err = gs .InitializeRootManifestAndLock (p .Manifest , p .Lock )
146
+ if err != nil {
147
+ return err
148
+ }
139
149
}
140
150
141
151
rootAnalyzer .skipTools = true // Don't import external config during solve for now
152
+ copyLock := * p .Lock // Copy lock before solving. Use this to separate new lock projects from solved lock
142
153
143
154
params := gps.SolveParameters {
144
155
RootDir : root ,
@@ -164,8 +175,7 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
164
175
}
165
176
p .Lock = dep .LockFromSolution (soln )
166
177
167
- rootAnalyzer .FinalizeRootManifestAndLock (p .Manifest , p .Lock )
168
- gs .FinalizeRootManifestAndLock (p .Manifest , p .Lock )
178
+ rootAnalyzer .FinalizeRootManifestAndLock (p .Manifest , p .Lock , copyLock )
169
179
170
180
// Run gps.Prepare with appropriate constraint solutions from solve run
171
181
// to generate the final lock memo.
0 commit comments