diff --git a/aws/iam_policy_model.go b/aws/iam_policy_model.go index 4bb627955dcd..8726c082663b 100644 --- a/aws/iam_policy_model.go +++ b/aws/iam_policy_model.go @@ -177,12 +177,12 @@ func (cs *IAMPolicyStatementConditionSet) UnmarshalJSON(b []byte) error { for test_key, test_value := range data { for var_key, var_values := range test_value { - switch var_values.(type) { + switch var_values := var_values.(type) { case string: - out = append(out, IAMPolicyStatementCondition{Test: test_key, Variable: var_key, Values: []string{var_values.(string)}}) + out = append(out, IAMPolicyStatementCondition{Test: test_key, Variable: var_key, Values: []string{var_values}}) case []interface{}: values := []string{} - for _, v := range var_values.([]interface{}) { + for _, v := range var_values { values = append(values, v.(string)) } out = append(out, IAMPolicyStatementCondition{Test: test_key, Variable: var_key, Values: values}) diff --git a/aws/resource_aws_iam_server_certificate.go b/aws/resource_aws_iam_server_certificate.go index e3402f032159..644789ce8ffb 100644 --- a/aws/resource_aws_iam_server_certificate.go +++ b/aws/resource_aws_iam_server_certificate.go @@ -215,11 +215,11 @@ func normalizeCert(cert interface{}) string { } var rawCert string - switch cert.(type) { + switch cert := cert.(type) { case string: - rawCert = cert.(string) + rawCert = cert case *string: - rawCert = *cert.(*string) + rawCert = *cert default: return "" } diff --git a/aws/resource_aws_instance.go b/aws/resource_aws_instance.go index 602d6a7fea55..8547976e6da7 100644 --- a/aws/resource_aws_instance.go +++ b/aws/resource_aws_instance.go @@ -136,9 +136,9 @@ func resourceAwsInstance() *schema.Resource { return false }, StateFunc: func(v interface{}) string { - switch v.(type) { + switch v := v.(type) { case string: - return userDataHashSum(v.(string)) + return userDataHashSum(v) default: return "" } diff --git a/aws/resource_aws_key_pair.go b/aws/resource_aws_key_pair.go index 48f954b9cca5..2fc2476397d5 100644 --- a/aws/resource_aws_key_pair.go +++ b/aws/resource_aws_key_pair.go @@ -47,9 +47,9 @@ func resourceAwsKeyPair() *schema.Resource { Required: true, ForceNew: true, StateFunc: func(v interface{}) string { - switch v.(type) { + switch v := v.(type) { case string: - return strings.TrimSpace(v.(string)) + return strings.TrimSpace(v) default: return "" } diff --git a/aws/resource_aws_launch_configuration.go b/aws/resource_aws_launch_configuration.go index c72376566d7e..68ab22f61ac2 100644 --- a/aws/resource_aws_launch_configuration.go +++ b/aws/resource_aws_launch_configuration.go @@ -73,9 +73,9 @@ func resourceAwsLaunchConfiguration() *schema.Resource { ForceNew: true, ConflictsWith: []string{"user_data_base64"}, StateFunc: func(v interface{}) string { - switch v.(type) { + switch v := v.(type) { case string: - return userDataHashSum(v.(string)) + return userDataHashSum(v) default: return "" } diff --git a/aws/resource_aws_opsworks_application.go b/aws/resource_aws_opsworks_application.go index ef983b6a4928..224bde4ba1ef 100644 --- a/aws/resource_aws_opsworks_application.go +++ b/aws/resource_aws_opsworks_application.go @@ -168,9 +168,9 @@ func resourceAwsOpsworksApplication() *schema.Resource { Type: schema.TypeString, Required: true, StateFunc: func(v interface{}) string { - switch v.(type) { + switch v := v.(type) { case string: - return strings.TrimSpace(v.(string)) + return strings.TrimSpace(v) default: return "" } @@ -181,9 +181,9 @@ func resourceAwsOpsworksApplication() *schema.Resource { Required: true, Sensitive: true, StateFunc: func(v interface{}) string { - switch v.(type) { + switch v := v.(type) { case string: - return strings.TrimSpace(v.(string)) + return strings.TrimSpace(v) default: return "" } @@ -193,9 +193,9 @@ func resourceAwsOpsworksApplication() *schema.Resource { Type: schema.TypeString, Optional: true, StateFunc: func(v interface{}) string { - switch v.(type) { + switch v := v.(type) { case string: - return strings.TrimSpace(v.(string)) + return strings.TrimSpace(v) default: return "" } diff --git a/aws/resource_aws_s3_bucket.go b/aws/resource_aws_s3_bucket.go index 4212a4acda39..c8c75e81ce71 100644 --- a/aws/resource_aws_s3_bucket.go +++ b/aws/resource_aws_s3_bucket.go @@ -2280,9 +2280,9 @@ func removeNil(data map[string]interface{}) map[string]interface{} { continue } - switch v.(type) { + switch v := v.(type) { case map[string]interface{}: - withoutNil[k] = removeNil(v.(map[string]interface{})) + withoutNil[k] = removeNil(v) default: withoutNil[k] = v } diff --git a/aws/resource_aws_security_group.go b/aws/resource_aws_security_group.go index 0ea62cc2057a..887786bc8351 100644 --- a/aws/resource_aws_security_group.go +++ b/aws/resource_aws_security_group.go @@ -1337,9 +1337,9 @@ func idHash(rType, protocol string, toPort, fromPort int64, self bool) string { // protocolStateFunc ensures we only store a string in any protocol field func protocolStateFunc(v interface{}) string { - switch v.(type) { + switch v := v.(type) { case string: - p := protocolForValue(v.(string)) + p := protocolForValue(v) return p default: log.Printf("[WARN] Non String value given for Protocol: %#v", v) diff --git a/aws/resource_aws_spot_fleet_request.go b/aws/resource_aws_spot_fleet_request.go index a145b648408a..f5024f20d9e4 100644 --- a/aws/resource_aws_spot_fleet_request.go +++ b/aws/resource_aws_spot_fleet_request.go @@ -239,9 +239,9 @@ func resourceAwsSpotFleetRequest() *schema.Resource { Optional: true, ForceNew: true, StateFunc: func(v interface{}) string { - switch v.(type) { + switch v := v.(type) { case string: - return userDataHashSum(v.(string)) + return userDataHashSum(v) default: return "" } diff --git a/staticcheck.conf b/staticcheck.conf index 4d99a4ccedcc..0f0220901185 100644 --- a/staticcheck.conf +++ b/staticcheck.conf @@ -4,6 +4,5 @@ checks = [ "-ST1000", "-ST1003", "-ST1005", - "-ST1012", - "-S1034" + "-ST1012" ]