32
32
33
33
The commands are:
34
34
35
+ vendor Check out revisions defined in Godeps file in ./vendor directory.
35
36
restore Check out revisions defined in Godeps file to $GOPATH.
36
37
save Saves currently checked-out dependencies from $GOPATH to Godeps file.
37
38
brew Outputs homebrew go_resource entries to stdout.
@@ -65,13 +66,17 @@ func main() {
65
66
66
67
switch args [0 ] {
67
68
case "save" , "bootstrap" :
68
- splash (wd , gopath )
69
+ splash (wd , "NA" , gopath )
69
70
save (wd , gopath , verbose )
71
+ case "vendor" :
72
+ path := filepath .Join (wd , "vendor" )
73
+ splash (wd , path , gopath )
74
+ restore (wd , path , verbose )
70
75
case "restore" , "get" , "sync" , "checkout" :
71
- splash (wd , gopath )
72
- restore (wd , gopath , verbose )
76
+ path := filepath .Join (gopath , "src" )
77
+ splash (wd , path , gopath )
78
+ restore (wd , path , verbose )
73
79
case "brew" , "homebrew" :
74
- splash (wd , gopath )
75
80
homebrew (wd , gopath , verbose )
76
81
case "version" :
77
82
fmt .Printf ("gdm - version %s\n " , Version )
@@ -80,10 +85,11 @@ func main() {
80
85
}
81
86
}
82
87
83
- func splash (wd , gopath string ) {
88
+ func splash (wd , path , gopath string ) {
84
89
fmt .Println ("======= Go Dependency Manager =======" )
85
- fmt .Println ("= working dir:" , wd )
86
- fmt .Println ("= GOPATH: " , gopath )
90
+ fmt .Println ("= working dir: " , wd )
91
+ fmt .Println ("= checkout dir:" , path )
92
+ fmt .Println ("= GOPATH: " , gopath )
87
93
fmt .Println ("=====================================" )
88
94
}
89
95
@@ -121,12 +127,7 @@ func getGoPath(wd string) (string, error) {
121
127
}
122
128
123
129
func homebrew (wd , gopath string , verbose bool ) {
124
- imports , err := ImportsFromPath (wd , gopath , verbose )
125
- if err != nil {
126
- fmt .Printf ("Fatal error: %s" , err )
127
- os .Exit (1 )
128
- }
129
-
130
+ imports := ImportsFromFile (filepath .Join (wd , DepsFile ))
130
131
fmt .Println ()
131
132
for _ , i := range imports {
132
133
fmt .Printf (" go_resource \" %s\" do\n " , i .ImportPath )
@@ -162,24 +163,24 @@ func save(wd, gopath string, verbose bool) {
162
163
w .Flush ()
163
164
}
164
165
165
- func restore (wd , gopath string , verbose bool ) {
166
+ func restore (wd , path string , verbose bool ) {
166
167
imports := ImportsFromFile (filepath .Join (wd , DepsFile ))
167
168
if Parallel {
168
- restoreParallel (imports , gopath , verbose )
169
+ restoreParallel (imports , path , verbose )
169
170
} else {
170
- restoreSerial (imports , gopath , verbose )
171
+ restoreSerial (imports , path , verbose )
171
172
}
172
173
}
173
174
174
- func restoreParallel (imports []* Import , gopath string , verbose bool ) {
175
+ func restoreParallel (imports []* Import , path string , verbose bool ) {
175
176
var wg sync.WaitGroup
176
177
wg .Add (len (imports ))
177
178
errC := make (chan error , len (imports ))
178
179
for _ , i := range imports {
179
180
i .Verbose = verbose
180
181
go func (I * Import ) {
181
182
defer wg .Done ()
182
- err := I .RestoreImport (gopath )
183
+ err := I .RestoreImport (path )
183
184
if err != nil {
184
185
errC <- err
185
186
}
@@ -199,9 +200,9 @@ func restoreParallel(imports []*Import, gopath string, verbose bool) {
199
200
}
200
201
}
201
202
202
- func restoreSerial (imports []* Import , gopath string , verbose bool ) {
203
+ func restoreSerial (imports []* Import , path string , verbose bool ) {
203
204
for _ , i := range imports {
204
205
i .Verbose = verbose
205
- i .RestoreImport (gopath )
206
+ i .RestoreImport (path )
206
207
}
207
208
}
0 commit comments