Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 378
Hassan Syed Avatar asked Aug 23 '19 16:08

Hassan Syed


People also ask

What does +incompatible mean in Go mod?

mod and go. sum files with the suffix +incompatible , indicating that the selected version is not compatible with the original API for that path.

Where are Go mod files stored?

What is Go Module. A Module is a collection of Go packages stored in a file tree under $GOPATH/pkg folder with a go. mod file at its root. This file defines the module's path, which is also the import path used for your project, and its dependency requirements, which are the other modules needed for a successful build.

What does Go mod tidy do?

go mod tidy cleans up unused dependencies or adds missing dependencies. go mod vendor copies all third-party dependencies to a vendor folder in your project root.

What is indirect in Go mod file?

Indirect Dependencies You may see some dependencies in your go. mod file that are indirect (denoted by // indirect ). This means that one of your dependencies doesn't have its own go. mod file, so, the dependencies that it imports are included in your project's go.


1 Answers

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.

like image 74
thepudds Avatar answered Nov 13 '22 03:11

thepudds