'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.



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1