Run go mod tidy before compilation

This commit is contained in:
Lea Anthony 2021-02-27 14:03:54 +11:00
commit bb8e848ef6
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405

View file

@ -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