-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Multiple directories do not sum correctly #452
Comments
Well that's embarrassing. In short I used a new bit of Go functionality inside the code walker https://github.com/boyter/gocodewalker by using errgroup.Group{} without actually realizing that its Anyway pushed out 2 releases, the first which fixes that, and the second which fixes the version (small but I wanted it fixed) https://github.com/boyter/scc/releases/tag/v3.3.2 I had a feeling moving over to the new walker would cause an issue somewhere. Thanks for picking it up so quickly. |
Hey @boyter i think the go team fixed that behavior on go 1.22 https://go.dev/blog/loopvar-preview maybe worth looking into upgrading go to 1.22, let me know what you think, I might have miss understood the underlying problem |
@Tommy-42 oddly I am using Go 1.22 to compile it. I thought it would have resolved it as well, but not in this case. Although it could be falling back to older style of loop as its Go 1.20 in the go.mod |
@boyter I did few test and it is kinda weird behavior I removed your fix ( copy var ) from the gocodewolker : if len(f.directories) != 0 {
eg := errgroup.Group{}
for _, directory := range f.directories {
eg.Go(func() error {
return f.walkDirectoryRecursive(directory, []gitignore.GitIgnore{}, []gitignore.GitIgnore{})
})
}
err = eg.Wait()
} else {
if f.directory != "" {
err = f.walkDirectoryRecursive(f.directory, []gitignore.GitIgnore{}, []gitignore.GitIgnore{})
}
} ✗ go version
go version go1.22.2 darwin/arm64 I tried : it didn't sum both directory, I also tried to update the then I looked at the link I sent you and they say that you can try it out, with : and it worked, the sum of both directory was done I found the proposal : golang/go#60078 it appears to be done and merged on 1.22 so I am not sure whats the underlying problem there both following links state that it should work I don't know if it is because of the |
Odd.... One I will want to revisit that's for sure because I knew I was using Go 1.22 hence not capturing the variable, but as you say perhaps all the go.mod files need to be on 1.22 in order to ensure it works. Sounds like a great "gotcha" blog post that would get attention though. |
Ok I tried that : I cloned the I modified the
I deleted the vendor folder run and it worked. I changed back the go.mod to So I guess we have our answer |
Well that answers that. Thanks for the investigation. |
Describe the bug
When using scc on multiple directories doesn't sum both directories independently.
To Reproduce
Expected behavior
Giving multiple directories to scc must compute the sum of all the stats from the different directories.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: