-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: cmd/go: ignore directories containing .goignore
in file scans
#30058
Comments
/cc @robpike |
I presume this would extend the following bit of
Or is it fine for |
Now that I think about it, |
To generalize this behavior, should we also ignore top-level directories under |
This can't be done in just cmd/doc. If we're going to do it, it should be globally, in cmd/go, go/build, etc. (And we can't start parsing It's unfortunate to have the definition of Go packages depending on or working around problems specific to other languages. On the other hand 15 GB is pretty big. |
If we do this, we have to write: Directory and file names that begin with "." or "_" are ignored by the go tool, That's a bit strange, to call out Node explicitly like that. Are there any other giant directories to avoid too? We could also make it user-configurable in some way, but then the meaning of things like 'go list foo/...' or 'go install foo/...' becomes configuration-specific, which we've tried hard to avoid. |
I've been watching this as I've been affected heavily in the past with this via I agree that it is unfortunate to have to call out a specific language (and all derivatives of), however in the scope of web development as a practice today with |
I've also had this problem with Carthage. Looking at my |
Some more discussion here - #16427. I agree that we should make it user-configurable. Hardcoding At the expense of adding new knobs, I think having a |
I agree that adding |
Please don't create more dot files. If the tools need configuration, use a single file. |
The suggestion is basically to rename It occurs to me that if we adopt #30411 then another possible approach would be to use an environment variable. |
What about go env -w GOIGNORE= (as Ian suggested)? This would apply to We've been circling various options here for a while. This seems like the least bad. |
Ignore lists like this tend to grow slowly over time. This is a nice fit for a text file, which is easy to edit and append to. Env vars are much less edit-friendly. Every time I type |
Ian suggests that we might also consider a special file in the directory to be ignored. For example, we could say that when the go command walks into a directory and finds a file named Thoughts? Name bikesheds? |
That can be a bit annoying to work with for directories that sometimes get removed and then replaced with newer versions or for directories owned by a tool that then needs to be told to ignore the sentinel file. It semi-makes sense to include the blacklist in |
A major problem that I see is that it will need .gitignore'd directories to be in the filesystem. For eg. Moreover, this will create multiple files peppered throughout the repo compared to a single file. Also, now it becomes harder to know what directories are ignored at once. What is the advantage of this solution over having a single dot file, since both are using a special magic file anyways (which I thought was the main point of contention) ? |
Typically the directories that should be ignored don't have to live in a Go repo at all. After all, by definition they don't contain any Go code. So the advantage of a file in a directory is that only people who create that directory will need to put the file in it. If we use a single dot file, it's hard to avoid putting that file into the Go repo, but now people who create a directory that doesn't contain any Go code have to maintain a local patch to the Go repo. (That argument does not apply to (I'm not saying we have to do it that way, I'm just answering the question about the advantage of this approach over a single dot file.) |
Android has a |
Thanks for the clarification Ian. The only issue I see is that new users cloning a node repo have to traverse inside the |
I'm concerned that this won't play well with external dependencies, either managed via git submodules or via some package manager. To get the go tool to ignore them, we'd have to add a Go-specific file to a completely non-Go repository; I can't imagine other projects being happy about that. The alternative is to add the file yourself after downloading the code, but dirtying the repo will also be an annoyance; it'll cause git submodule pain, any package manager that checks directory contents for security purposes may fail, etc. |
is there a better solution than the empty |
I think node_modules is hardcoded and is always ignored by the Go tooling (please correct me if I'm wrong). |
Hi @burdiyan, go1.17.3 linux/amd64 |
As #45713 has landed, does anybody know how to ignore a |
See golang/go#30058 (comment) Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
See golang/go#30058 (comment) Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
* Remove as many hard-coded go versions as possible * Also regenerate go.mod/go.sum for CI dependencies * Add empty go.mod to ignore build directory from go tools See golang/go#30058 (comment) * Add missing dependencies to Makefile targets * Set git config advice.detachedHead=false for embedded binaries So that there's less log spam * Change go get to go install for Konnectivity Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Kubernetes 1.24 switched to go 1.18.1 as well. * Remove as many hard-coded go versions as possible * Also regenerate go.mod/go.sum for CI dependencies * Add empty go.mod to ignore build directory from go tools See golang/go#30058 (comment) * Add missing dependencies to Makefile targets * Set git config advice.detachedHead=false for embedded binaries So that there's less log spam * Change go get to go install for Konnectivity Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Kubernetes 1.24 switched to go 1.18.1 as well. * Remove as many hard-coded go versions as possible * Also regenerate go.mod/go.sum for CI dependencies * Add empty go.mod to ignore build directory from go tools See golang/go#30058 (comment) * Add missing dependencies to Makefile targets * Set git config advice.detachedHead=false for embedded binaries So that there's less log spam * Change go get to go install for Konnectivity Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Kubernetes 1.24 switched to go 1.18.1 as well. * Remove as many hard-coded go versions as possible * Also regenerate go.mod/go.sum for CI dependencies * Add empty go.mod to ignore build directory from go tools See golang/go#30058 (comment) * Add missing dependencies to Makefile targets * Set git config advice.detachedHead=false for embedded binaries So that there's less log spam * Change go get to go install for Konnectivity Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Kubernetes 1.24 switched to go 1.18.1 as well. * Remove as many hard-coded go versions as possible * Also regenerate go.mod/go.sum for CI dependencies * Add empty go.mod to ignore build directory from go tools See golang/go#30058 (comment) * Add missing dependencies to Makefile targets * Set git config advice.detachedHead=false for embedded binaries So that there's less log spam * Change go get to go install for Konnectivity Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
When I run
I echo this sentiment: the We cannot use the What would be ideal is a way of telling |
Kubernetes 1.24 switched to go 1.18.1 as well. * Remove as many hard-coded go versions as possible * Also regenerate go.mod/go.sum for CI dependencies * Add empty go.mod to ignore build directory from go tools See golang/go#30058 (comment) * Add missing dependencies to Makefile targets * Set git config advice.detachedHead=false for embedded binaries So that there's less log spam * Change go get to go install for Konnectivity Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
Kubernetes 1.24 switched to go 1.18.1 as well. * Remove as many hard-coded go versions as possible * Also regenerate go.mod/go.sum for CI dependencies * Add empty go.mod to ignore build directory from go tools See golang/go#30058 (comment) * Add missing dependencies to Makefile targets * Set git config advice.detachedHead=false for embedded binaries So that there's less log spam * Change go get to go install for Konnectivity Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
I'm also running into this, is there a way to get it to ignore node_modules? |
@paralin it's pretty obvious by now they don't care at all. Their so-called solution is BS. find * -type d -name "node_modules" -exec touch {}/go.mod \; I also get |
Ended up resolving it by ensuring that "go.mod" and "go.sum" were published with the npm package I was importing. However, it's a bit concerning to me that potentially some other npm module added could have some Go code in it which ends up causing the Go compiler to fetch random packages & modify my project's go.mod. |
@bradfitz mentioned
go doc
could special-case node_modules for exclusion.If you have many client/server projects in $GOPATH,
node_modules
can quickly bloat and causego doc
to resolve slowly—this is especially noticeable in editors which usego doc
to display inline documentation (see vscode issue).I recursively removed my
node_modules
(15gb, crazy I know), here are the results before and after:The text was updated successfully, but these errors were encountered: