From bb8e848ef6100d544f712fca5f842fb93d518b0d Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 27 Feb 2021 14:03:54 +1100 Subject: [PATCH] Run go mod tidy before compilation --- v2/pkg/commands/build/base.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/v2/pkg/commands/build/base.go b/v2/pkg/commands/build/base.go index 6a712a93e..9b38ffc5f 100644 --- a/v2/pkg/commands/build/base.go +++ b/v2/pkg/commands/build/base.go @@ -145,6 +145,13 @@ func (b *BaseBuilder) CleanUp() { // CompileProject compiles the project func (b *BaseBuilder) CompileProject(options *Options) error { + // Run go mod tidy first + cmd := exec.Command(options.Compiler, "mod", "tidy") + err := cmd.Run() + if err != nil { + return err + } + // Default go build command commands := slicer.String([]string{"build"}) @@ -188,7 +195,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error { // Get application build directory appDir := options.BuildDirectory - err := cleanBuildDirectory(options) + err = cleanBuildDirectory(options) if err != nil { return err } @@ -211,7 +218,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error { options.CompiledBinary = compiledBinary // Create the command - cmd := exec.Command(options.Compiler, commands.AsSlice()...) + cmd = exec.Command(options.Compiler, commands.AsSlice()...) // Set the directory cmd.Dir = b.projectData.Path