@@ -574,7 +574,7 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
574
574
Source : instr .id .Source ,
575
575
Constraint : instr .constraint ,
576
576
}
577
- } else {
577
+ // } else {
578
578
// TODO(sdboyer) hoist a constraint into the manifest from the lock
579
579
}
580
580
}
@@ -586,12 +586,15 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
586
586
sort .Strings (reqlist )
587
587
588
588
sw , err := dep .NewSafeWriter (nil , p .Lock , dep .LockFromSolution (solution ), dep .VendorOnChanged )
589
+ if err != nil {
590
+ return err
591
+ }
592
+
589
593
if cmd .dryRun {
590
594
return sw .PrintPreparedActions (ctx .Out )
591
595
}
592
596
593
- err = errors .Wrap (sw .Write (p .AbsRoot , sm , true ), "grouped write of manifest, lock and vendor" )
594
- if err != nil {
597
+ if err := errors .Wrap (sw .Write (p .AbsRoot , sm , true ), "grouped write of manifest, lock and vendor" ); err != nil {
595
598
return err
596
599
}
597
600
@@ -601,8 +604,8 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
601
604
return errors .Wrapf (err , "opening %s failed" , dep .ManifestName )
602
605
}
603
606
604
- _ , err = f .Write (extra )
605
- if err != nil {
607
+ if _ , err : = f .Write (extra ); err != nil {
608
+ f . Close ()
606
609
return errors .Wrapf (err , "writing to %s failed" , dep .ManifestName )
607
610
}
608
611
0 commit comments