Skip to content

Commit 9741b36

Browse files
authored
fix: fix slice init length (#4133)
<!-- Thanks for sending a PR! Before submitting: 1. If this is your first PR, please read CONTRIBUTING.md and sign the CLA first. We cannot review code without a signed CLA. 2. Please file an issue *first*. All features and most bug fixes should have an associated issue with a design discussed and decided upon. Small bug fixes and documentation improvements don't need issues. 3. New features and bug fixes must have tests. Documentation may need to be updated. If you're unsure what to update, send the PR, and we'll discuss in review. 4. Note that PRs updating dependencies and new Go versions are not accepted. Please file an issue instead. --> **What type of PR is this?** > Bug fix **What does this PR do? Why is it needed?** The intention here should be to initialize a slice with a capacity of `len(includeSet)` rather than initializing the length of this slice. The online demo: https://go.dev/play/p/q1BcVCmvidW **Which issues(s) does this PR fix?** Fixes # **Other notes for review**
1 parent 76ada20 commit 9741b36

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

go/tools/builders/compilepkg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ func compileArchive(
403403
for _, hdr := range srcs.hSrcs {
404404
includeSet[filepath.Dir(hdr.filename)] = struct{}{}
405405
}
406-
includes := make([]string, len(includeSet))
406+
includes := make([]string, 0, len(includeSet))
407407
for inc := range includeSet {
408408
includes = append(includes, inc)
409409
}

0 commit comments

Comments
 (0)