diff --git a/autoscaling/autoscaling.go b/autoscaling/autoscaling.go index 6f64bff3..b27220a5 100644 --- a/autoscaling/autoscaling.go +++ b/autoscaling/autoscaling.go @@ -136,16 +136,16 @@ type Tag struct { } type LaunchConfiguration struct { - AssociatePublicIpAddress bool `xml:"AssociatePublicIpAddress"` - IamInstanceProfile string `xml:"IamInstanceProfile"` - ImageId string `xml:"ImageId"` - InstanceType string `xml:"InstanceType"` - KernelId string `xml:"KernelId"` - KeyName string `xml:"KeyName"` - SpotPrice string `xml:"SpotPrice"` - Name string `xml:"LaunchConfigurationName"` - SecurityGroups []string `xml:"SecurityGroups>member"` - UserData []byte `xml:"UserData"` + AssociatePublicIpAddress bool `xml:"AssociatePublicIpAddress"` + IamInstanceProfile string `xml:"IamInstanceProfile"` + ImageId string `xml:"ImageId"` + InstanceType string `xml:"InstanceType"` + KernelId string `xml:"KernelId"` + KeyName string `xml:"KeyName"` + SpotPrice string `xml:"SpotPrice"` + Name string `xml:"LaunchConfigurationName"` + SecurityGroups []string `xml:"SecurityGroups>member"` + UserData []byte `xml:"UserData"` BlockDevices []BlockDeviceMapping `xml:"BlockDeviceMappings>member"` } diff --git a/autoscaling/autoscaling_test.go b/autoscaling/autoscaling_test.go index c7f20cfc..fb60ebe3 100644 --- a/autoscaling/autoscaling_test.go +++ b/autoscaling/autoscaling_test.go @@ -48,7 +48,7 @@ func (s *S) Test_CreateAutoScalingGroup(c *C) { TerminationPolicies: []string{"ClosestToNextInstanceHour", "OldestInstance"}, Name: "foobar", Tags: []autoscaling.Tag{ - autoscaling.Tag{ + { Key: "foo", Value: "bar", }, @@ -79,7 +79,7 @@ func (s *S) Test_CreateLaunchConfiguration(c *C) { KeyName: "foobar", Name: "i-141421", UserData: "#!/bin/bash\necho Hello\n", - BlockDevices: []autoscaling.BlockDeviceMapping{ + BlockDevices: []autoscaling.BlockDeviceMapping{ {DeviceName: "/dev/sdb", VirtualName: "ephemeral0"}, {DeviceName: "/dev/sdc", SnapshotId: "snap-a08912c9", DeleteOnTermination: true}, }, diff --git a/ec2/ec2i_test.go b/ec2/ec2i_test.go index 8b025dfb..5f7ad360 100644 --- a/ec2/ec2i_test.go +++ b/ec2/ec2i_test.go @@ -188,7 +188,7 @@ func (s *ClientTests) TestRegions(c *C) { errs <- err }(region) } - for _ = range allRegions { + for range allRegions { err := <-errs if err != nil { ec2_err, ok := err.(*ec2.Error) diff --git a/ec2/sign.go b/ec2/sign.go index bffc3c7e..e66542a2 100644 --- a/ec2/sign.go +++ b/ec2/sign.go @@ -27,7 +27,7 @@ func sign(auth aws.Auth, method, path string, params map[string]string, host str // from the natural order of the encoded value of key=value. // Percent and equals affect the sorting order. var keys, sarray []string - for k, _ := range params { + for k := range params { keys = append(keys, k) } sort.Strings(keys) diff --git a/elb/elb_test.go b/elb/elb_test.go index d0a5caab..ed57193b 100644 --- a/elb/elb_test.go +++ b/elb/elb_test.go @@ -77,7 +77,7 @@ func (s *S) TestCreateLoadBalancer(c *C) { options := elb.CreateLoadBalancer{ AvailZone: []string{"us-east-1a"}, - Listeners: []elb.Listener{elb.Listener{ + Listeners: []elb.Listener{{ InstancePort: 80, InstanceProtocol: "http", SSLCertificateId: "needToAddASSLCertToYourAWSAccount", diff --git a/exp/sns/topic.go b/exp/sns/topic.go index 4d82cbfb..83c34a2c 100644 --- a/exp/sns/topic.go +++ b/exp/sns/topic.go @@ -43,7 +43,7 @@ func (sns *SNS) ListTopics(NextToken *string) (resp *ListTopicsResp, err error) params["NextToken"] = *NextToken } err = sns.query(params, resp) - for i, _ := range resp.Topics { + for i := range resp.Topics { resp.Topics[i].SNS = sns } return diff --git a/rds/rds_test.go b/rds/rds_test.go index fcc6dd93..6a5bd317 100644 --- a/rds/rds_test.go +++ b/rds/rds_test.go @@ -383,27 +383,27 @@ func (s *S) Test_ModifyDBParameterGroup(c *C) { options := rds.ModifyDBParameterGroup{ DBParameterGroupName: "mydbparamgroup3", Parameters: []rds.Parameter{ - rds.Parameter{ + { ApplyMethod: "immediate", ParameterName: "character_set_server", ParameterValue: "utf8", }, - rds.Parameter{ + { ApplyMethod: "immediate", ParameterName: "character_set_client", ParameterValue: "utf8", }, - rds.Parameter{ + { ApplyMethod: "immediate", ParameterName: "character_set_results", ParameterValue: "utf8", }, - rds.Parameter{ + { ApplyMethod: "immediate", ParameterName: "collation_server", ParameterValue: "utf8_unicode_ci", }, - rds.Parameter{ + { ApplyMethod: "immediate", ParameterName: "collation_connection", ParameterValue: "utf8_unicode_ci", diff --git a/rds/responses_test.go b/rds/responses_test.go index 048557f4..7ba2564c 100644 --- a/rds/responses_test.go +++ b/rds/responses_test.go @@ -585,7 +585,6 @@ var DescribeDBParameterGroupsExample = ` ` - var DeleteDBParameterGroupExample = ` diff --git a/route53/route53_test.go b/route53/route53_test.go index 092c8174..64560381 100644 --- a/route53/route53_test.go +++ b/route53/route53_test.go @@ -120,7 +120,7 @@ func TestChangeResourceRecordSets(t *testing.T) { req := &ChangeResourceRecordSetsRequest{ Comment: "Test", Changes: []Change{ - Change{ + { Action: "CREATE", Record: ResourceRecordSet{ Name: "foo.hashicorp.com", diff --git a/s3/s3.go b/s3/s3.go index dbeec6ef..b816ee8c 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -16,7 +16,6 @@ import ( "encoding/base64" "encoding/xml" "fmt" - "github.com/mitchellh/goamz/aws" "io" "io/ioutil" "log" @@ -27,6 +26,8 @@ import ( "strconv" "strings" "time" + + "github.com/mitchellh/goamz/aws" ) const debug = false @@ -532,7 +533,7 @@ func (b *Bucket) List(prefix, delim, marker string, max int) (result *ListResp, return result, nil } -// Returns a mapping of all key names in this bucket to Key objects +// GetBucketContents returns a mapping of all key names in this bucket to Key objects func (b *Bucket) GetBucketContents() (*map[string]Key, error) { bucket_contents := map[string]Key{} prefix := "" diff --git a/s3/s3i_test.go b/s3/s3i_test.go index 9b3145d8..f3b22b0b 100644 --- a/s3/s3i_test.go +++ b/s3/s3i_test.go @@ -8,13 +8,14 @@ import ( "net/http" "strings" + "net" + "sort" + "time" + "github.com/mitchellh/goamz/aws" "github.com/mitchellh/goamz/s3" "github.com/mitchellh/goamz/testutil" . "github.com/motain/gocheck" - "net" - "sort" - "time" ) // AmazonServer represents an Amazon S3 server. @@ -153,7 +154,7 @@ func get(url string) ([]byte, error) { return nil, err } data, err := ioutil.ReadAll(resp.Body) - resp.Body.Close() + defer resp.Body.Close() if err != nil { if attempt.HasNext() { continue @@ -172,7 +173,10 @@ func (s *ClientTests) TestBasicFunctionality(c *C) { err = b.Put("name", []byte("yo!"), "text/plain", s3.PublicRead) c.Assert(err, IsNil) - defer b.Del("name") + defer func() { + err = b.Del("name") + c.Assert(err, IsNil) + }() data, err := b.Get("name") c.Assert(err, IsNil) @@ -225,6 +229,7 @@ func (s *ClientTests) TestBasicFunctionality(c *C) { func (s *ClientTests) TestCopy(c *C) { b := testBucket(s.s3) err := b.PutBucket(s3.PublicRead) + c.Assert(err, IsNil) err = b.Put("name+1", []byte("yo!"), "text/plain", s3.PublicRead) c.Assert(err, IsNil) @@ -270,7 +275,7 @@ func (s *ClientTests) TestRegions(c *C) { errs <- err }(region) } - for _ = range aws.Regions { + for range aws.Regions { err := <-errs if err != nil { s3_err, ok := err.(*s3.Error) @@ -486,7 +491,10 @@ func (s *ClientTests) TestMultiComplete(c *C) { multi, err := b.InitMulti("multi", "text/plain", s3.Private) c.Assert(err, IsNil) c.Assert(multi.UploadId, Matches, ".+") - defer multi.Abort() + defer func() { + err = multi.Abort() + c.Assert(err, IsNil) + }() // Minimum size S3 accepts for all but the last part is 5MB. data1 := make([]byte, 5*1024*1024) @@ -526,8 +534,10 @@ func (s *ClientTests) TestListMulti(c *C) { // Ensure an empty state before testing its behavior. multis, _, err := b.ListMulti("", "") + c.Assert(err, IsNil) + for _, m := range multis { - err := m.Abort() + err = m.Abort() c.Assert(err, IsNil) } @@ -579,7 +589,7 @@ func (s *ClientTests) TestListMulti(c *C) { c.Assert(multis[0].UploadId, Matches, ".+") for attempt := attempts.Start(); attempt.Next() && len(multis) < 2; { - multis, prefixes, err = b.ListMulti("", "") + multis, _, err = b.ListMulti("", "") c.Assert(err, IsNil) } multis, prefixes, err = b.ListMulti("a/", "/")