Hassan Syed
Hassan Syed

Reputation: 20475

Stop the go mod tool from parsing certain directories

I am using a mono repo and I download certain tools under the project tree (istio). Running go get -u or go mod tidy causes the main go.mod to get updated with irrelevant deps.

How do I exclude certain src subpaths for consideration.

Note:

This does not do the trick as the subdirectories I want to exclude do have go files in them.

Upvotes: 17

Views: 9156

Answers (1)

thepudds
thepudds

Reputation: 5284

I think your two main options are:

  1. A go.mod in a directory will cause that directory and all of its subdirectories to be excluded from the top-level Go module.

  2. Use a leading underscore as Peter suggested, or a leading ..

If neither of those are appropriate, please add a comment explaining why, ideally including an error message or some other set of details about what happened when you tried.

Upvotes: 24

Related Questions