Migrate existing Beat to go modules
editMigrate existing Beat to go modules
editGet started by making sure the contents of the vendored beats folder is
pushed to a remote repository. Otherwise, go will overwrite the folder
with the selected revision of github.com/elastic/beats
.
The following command will initialize a new module in your repo.
go mod init
Make sure to add the approprite replace
directives from the go.mod
file
of Beats: https://github.com/elastic/beats/tree/master/go.mod
Unfortunately, this workaround is needed to make sure your Beat can be compiled.
To depend on the latest master
of github.com/elastic/beats
run the following command:
go get github.com/elastic/beats@master
We suggest you read the following section to learn about maintaining dependencies using go modules: * How to upgrade and downgrade dependencies
Please note that it is your choice whether you put dependencies in the folder vendor or not.
If you choose to abandon the vendor folder, you have to adjust the following things in your Beat:
-
add
devtools.CrossBuildMountModcache = true
to themagefile.go
of your Beat -
modify the path to
ES_BEATS
in theMakefile
so it points to the folder under the module cache (go list -m -f '{{.Dir}}' $ES_BEATS_IMPORT_PATH
)