From bd397253a4800e05ca9add513c8bca008248c98f Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Wed, 7 Jul 2021 20:45:51 +0200 Subject: [PATCH] Run "go mod tidy" during build to comply with https://blog.golang.org/go116-module-changes#TOC_3. --- internal/builder/builder.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/builder/builder.go b/internal/builder/builder.go index 626e7bb..88ebd98 100644 --- a/internal/builder/builder.go +++ b/internal/builder/builder.go @@ -127,6 +127,10 @@ func Build(bin string) error { // we also print back the temp WORK directory // go has built. We will reuse it for our suite workdir. temp := fmt.Sprintf(filepath.Join("%s", "temp-%d.test"), os.TempDir(), time.Now().UnixNano()) + modTidyOutput, err := exec.Command("go", "mod", "tidy").CombinedOutput() + if err != nil { + return fmt.Errorf("failed to tidy modules in tested package: %s, reason: %v, output: %s", abs, err, string(modTidyOutput)) + } testOutput, err := exec.Command("go", "test", "-c", "-work", "-o", temp).CombinedOutput() if err != nil { return fmt.Errorf("failed to compile tested package: %s, reason: %v, output: %s", abs, err, string(testOutput))