Add a Go Module¶
The repository contains a few submodules. To add a new one and ensure it is tested, follow the following steps:
-
Create a directory for the module:
-
Initialize a new Go module:
-
Create a dummy root package file
doc.go
: -
Udpate the
modules.yml
file at the root of the repository with this content:independent
: Should it be importable as an independent module?should_tag
: Should the Agent pipeline tag it?test_targets
: Shouldgo test
target specific subfolders?
-
If you use your module in another module within
datadog-agent
, add therequire
andreplace
directives ingo.mod
.From the other module root, install the dependency with
Then add the replace directive in thego get
:go.mod
file:Example PR: #17350module github.com/DataDog/datadog-agent/myothermodule go 1.18 // Replace with local version replace github.com/DataDog/datadog-agent/path/to/mymodule => ../path/to/mymodule require ( github.com/DataDog/datadog-agent/path/to/mymodule v0.0.0-20230526143644-ed785d3a20d5 )