diff --git a/internal/backend/remote-state/gcs/backend.go b/internal/backend/remote-state/gcs/backend.go index 8bd622b457f5..8bab376bf35d 100644 --- a/internal/backend/remote-state/gcs/backend.go +++ b/internal/backend/remote-state/gcs/backend.go @@ -180,7 +180,7 @@ func (b *Backend) configure(ctx context.Context) error { if v, ok := data.GetOk("impersonate_service_account_delegates"); ok { d := v.([]interface{}) if len(delegates) > 0 { - delegates = make([]string, len(d)) + delegates = make([]string, 0, len(d)) } for _, delegate := range d { delegates = append(delegates, delegate.(string)) diff --git a/internal/cloud/backend_plan.go b/internal/cloud/backend_plan.go index 0678d9360835..b8cde60151f4 100644 --- a/internal/cloud/backend_plan.go +++ b/internal/cloud/backend_plan.go @@ -235,7 +235,7 @@ in order to capture the filesystem context the remote workspace expects: return nil, varDiags.Err() } - runVariables := make([]*tfe.RunVariable, len(variables)) + runVariables := make([]*tfe.RunVariable, 0, len(variables)) for name, value := range variables { runVariables = append(runVariables, &tfe.RunVariable{ Key: name, diff --git a/internal/e2e/e2e.go b/internal/e2e/e2e.go index e1ede0e46041..efdd2489a385 100644 --- a/internal/e2e/e2e.go +++ b/internal/e2e/e2e.go @@ -150,8 +150,8 @@ func (b *binary) Run(args ...string) (stdout, stderr string, err error) { // Path returns a file path within the temporary working directory by // appending the given arguments as path segments. func (b *binary) Path(parts ...string) string { - args := make([]string, len(parts)+1) - args[0] = b.workDir + args := make([]string, 0, len(parts)+1) + args = append(args, b.workDir) args = append(args, parts...) return filepath.Join(args...) } diff --git a/internal/plugin6/convert/schema.go b/internal/plugin6/convert/schema.go index 0bdf4e28402f..f3c59548cbdd 100644 --- a/internal/plugin6/convert/schema.go +++ b/internal/plugin6/convert/schema.go @@ -259,7 +259,7 @@ func configschemaObjectToProto(b *configschema.Object) *proto.Schema_Object { nesting = proto.Schema_Object_INVALID } - attributes := make([]*proto.Schema_Attribute, len(b.Attributes)) + attributes := make([]*proto.Schema_Attribute, 0, len(b.Attributes)) for _, name := range sortedKeys(b.Attributes) { a := b.Attributes[name]