]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modfetch: fix retractions slice initial length not zero
authorJames Yang <26634873@qq.com>
Tue, 23 May 2023 02:52:55 +0000 (02:52 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 19 Jun 2023 20:30:05 +0000 (20:30 +0000)
When make slice of retractions, it should have initial length zero, to append more VersionIntervals.

Currently without the zero length, the capacity used will be doubled after the appending, looks like a bug.

Change-Id: Id3acaeffe557ca1d15c864b0377a66fee3a41f6c
GitHub-Last-Rev: ed5fd5f6784c43195c531d8acc75560adff104ba
GitHub-Pull-Request: golang/go#60354
Reviewed-on: https://go-review.googlesource.com/c/go/+/497118
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/cmd/go/internal/modfetch/coderepo.go

index 50f4bb2b37a27075215d446d9ce335ac6ecdd146..8fe432a9f50197d3638ffd1c0658d876fa0c04b8 100644 (file)
@@ -1013,7 +1013,7 @@ func (r *codeRepo) retractedVersions(ctx context.Context) (func(string) bool, er
        if err != nil {
                return nil, err
        }
-       retractions := make([]modfile.VersionInterval, len(f.Retract))
+       retractions := make([]modfile.VersionInterval, 0, len(f.Retract))
        for _, r := range f.Retract {
                retractions = append(retractions, r.VersionInterval)
        }