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`
This commit is contained in:
Mohammed Al Sahaf 2021-02-05 20:49:17 +03:00 committed by GitHub
parent dabafeef18
commit e7b19b13a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -92,6 +92,12 @@ func (b Builder) Build(ctx context.Context, outputFile string) error {
log.Println("[INFO] Building Caddy") 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 // compile
cmd := buildEnv.newCommand("go", "build", cmd := buildEnv.newCommand("go", "build",
"-o", absOutputFile, "-o", absOutputFile,