From e7b19b13a231d41ecaf3a382086a00d7e56f6111 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Fri, 5 Feb 2021 20:49:17 +0300 Subject: [PATCH] Run `go mod tidy` in the build environment (#47) * Run `go mod tidy` in the build environment As of go 1.16, the `go {build,test}` commands don't modify the go.mod and go.sum files (see: https://golang.org/issue/40728). We, therefore, have to run `go mod tidy` to ensure the go.mod and go.sum files are consistent with the module requirements. Closes #46 * check the error of `go mod tidy` --- builder.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder.go b/builder.go index 3814fa2..ede9f32 100644 --- a/builder.go +++ b/builder.go @@ -92,6 +92,12 @@ func (b Builder) Build(ctx context.Context, outputFile string) error { log.Println("[INFO] Building Caddy") + // tidy the module to ensure go.mod and go.sum are consistent with the module prereq + tidyCmd := buildEnv.newCommand("go", "mod", "tidy") + if err := buildEnv.runCommand(ctx, tidyCmd, b.TimeoutGet); err != nil { + return err + } + // compile cmd := buildEnv.newCommand("go", "build", "-o", absOutputFile,