Skip to content
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

fix: fix slice init length #7731

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ratelimits/limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestLoadAndParseOverrideLimits(t *testing.T) {
// Burst cannot be 0.
_, err = loadAndParseOverrideLimits("testdata/busted_override_burst_0.yml")
test.AssertError(t, err, "single override limit with burst=0")
test.Assert(t, !os.IsNotExist(err), "test file should exist")
test.AssertContains(t, err.Error(), "invalid burst")

// Id cannot be empty.
_, err = loadAndParseOverrideLimits("testdata/busted_override_empty_id.yml")
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestLoadAndParseDefaultLimits(t *testing.T) {
// Burst cannot be 0.
_, err = loadAndParseDefaultLimits("testdata/busted_default_burst_0.yml")
test.AssertError(t, err, "single default limit with burst=0")
test.Assert(t, !os.IsNotExist(err), "test file should exist")
test.AssertContains(t, err.Error(), "invalid burst")

// Name cannot be empty.
_, err = loadAndParseDefaultLimits("testdata/busted_default_empty_name.yml")
Expand Down
2 changes: 1 addition & 1 deletion ratelimits/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ var stringToName = func() map[string]Name {

// limitNames is a slice of all rate limit names.
var limitNames = func() []string {
names := make([]string, len(nameToString))
names := make([]string, 0, len(nameToString))
for _, v := range nameToString {
names = append(names, v)
}
Expand Down
Loading