diff --git a/generator/_templates/beat/{beat}/tools/tools.go b/generator/_templates/beat/{beat}/tools/tools.go index 9c1319194d02..1ddaba8a29d7 100644 --- a/generator/_templates/beat/{beat}/tools/tools.go +++ b/generator/_templates/beat/{beat}/tools/tools.go @@ -6,12 +6,13 @@ package tools import ( + _ "github.com/blakesmith/ar" + _ "github.com/cavaliercoder/go-rpm" _ "github.com/magefile/mage" + _ "github.com/mitchellh/gox" _ "github.com/pierrre/gotestcover" _ "github.com/tsg/go-daemon" + _ "golang.org/x/lint/golint" _ "golang.org/x/tools/cmd/goimports" _ "gotest.tools/gotestsum/cmd" - - _ "github.com/mitchellh/gox" - _ "golang.org/x/lint/golint" ) diff --git a/generator/_templates/metricbeat/{beat}/tools/tools.go b/generator/_templates/metricbeat/{beat}/tools/tools.go index 9c1319194d02..1ddaba8a29d7 100644 --- a/generator/_templates/metricbeat/{beat}/tools/tools.go +++ b/generator/_templates/metricbeat/{beat}/tools/tools.go @@ -6,12 +6,13 @@ package tools import ( + _ "github.com/blakesmith/ar" + _ "github.com/cavaliercoder/go-rpm" _ "github.com/magefile/mage" + _ "github.com/mitchellh/gox" _ "github.com/pierrre/gotestcover" _ "github.com/tsg/go-daemon" + _ "golang.org/x/lint/golint" _ "golang.org/x/tools/cmd/goimports" _ "gotest.tools/gotestsum/cmd" - - _ "github.com/mitchellh/gox" - _ "golang.org/x/lint/golint" ) diff --git a/generator/common/Makefile b/generator/common/Makefile index ba3eb1af4776..8d82a444e84c 100644 --- a/generator/common/Makefile +++ b/generator/common/Makefile @@ -22,8 +22,6 @@ test: prepare-test test-package: test cd ${BEAT_PATH} ; \ export PATH=$${GOPATH}/bin:$${PATH}; \ - go mod tidy && \ - go mod download all && \ mage package .PHONY: prepare-test diff --git a/generator/common/beatgen/beatgen.go b/generator/common/beatgen/beatgen.go index 3cb101aa625b..c16b1e309ae7 100644 --- a/generator/common/beatgen/beatgen.go +++ b/generator/common/beatgen/beatgen.go @@ -126,6 +126,16 @@ func Generate() error { return errors.Wrap(err, "error while getting required beats version") } + // After fully populating go.mod download the deps to set the hashes + // within the go.sum. + if err = gotool.Mod.Download(); err != nil { + return errors.Wrap(err, "failed to download go.mod deps") + } + // Finally, cleanup any formatting issues in the go.mod/go.sum. + if err = gotool.Mod.Tidy(); err != nil { + return errors.Wrap(err, "error running 'go mod tidy'") + } + mg.Deps(setup.GitInit) if cfg["type"] == "metricbeat" {