Migrate existing Beat to go modulesedit

Get 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

To move the dependencies to vendor, you need to manually fetch the new magefile.go for newly generated Beats from the dev-tools of elastic/beats.

We suggest you read the following section to learn about maintaining dependencies using go modules: * How to upgrade and downgrade dependencies