@@ -160,29 +160,28 @@ func validateManifest(s string) ([]error, error) {
160
160
161
161
// ValidateProjectRoots validates the project roots present in manifest.
162
162
func ValidateProjectRoots (c * Ctx , m * Manifest , sm gps.SourceManager ) error {
163
- projectRoots := make ([]gps.ProjectRoot , 0 , len (m .Constraints )+ len (m .Ovr ))
164
- for pr := range m .Constraints {
165
- projectRoots = append (projectRoots , pr )
166
- }
167
- for pr := range m .Ovr {
168
- projectRoots = append (projectRoots , pr )
169
- }
170
-
171
163
// Channel to receive all the errors
172
- errorCh := make (chan error , len (projectRoots ))
164
+ errorCh := make (chan error , len (m . Constraints ) + len ( m . Ovr ))
173
165
174
166
var wg sync.WaitGroup
175
- for _ , pr := range projectRoots {
167
+
168
+ validate := func (pr gps.ProjectRoot ) {
169
+ defer wg .Done ()
170
+ origPR , err := sm .DeduceProjectRoot (string (pr ))
171
+ if err != nil {
172
+ errorCh <- err
173
+ } else if origPR != pr {
174
+ errorCh <- fmt .Errorf ("the name for %q should be changed to %q" , pr , origPR )
175
+ }
176
+ }
177
+
178
+ for pr := range m .Constraints {
176
179
wg .Add (1 )
177
- go func (pr gps.ProjectRoot ) {
178
- defer wg .Done ()
179
- origPR , err := sm .DeduceProjectRoot (string (pr ))
180
- if err != nil {
181
- errorCh <- err
182
- } else if origPR != pr {
183
- errorCh <- fmt .Errorf ("the name for %q should be changed to %q" , pr , origPR )
184
- }
185
- }(pr )
180
+ go validate (pr )
181
+ }
182
+ for pr := range m .Ovr {
183
+ wg .Add (1 )
184
+ go validate (pr )
186
185
}
187
186
188
187
wg .Wait ()
0 commit comments