Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

remove explicit type pointing during array initialization #263

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 10 additions & 10 deletions autoscaling/autoscaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
4 changes: 2 additions & 2 deletions autoscaling/autoscaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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},
},
Expand Down
2 changes: 1 addition & 1 deletion ec2/ec2i_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ec2/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion elb/elb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion exp/sns/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions rds/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion rds/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ var DescribeDBParameterGroupsExample = `
</DescribeDBParameterGroupsResponse>
`


var DeleteDBParameterGroupExample = `
<DeleteDBParameterGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
<ResponseMetadata>
Expand Down
2 changes: 1 addition & 1 deletion route53/route53_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestChangeResourceRecordSets(t *testing.T) {
req := &ChangeResourceRecordSetsRequest{
Comment: "Test",
Changes: []Change{
Change{
{
Action: "CREATE",
Record: ResourceRecordSet{
Name: "foo.hashicorp.com",
Expand Down
5 changes: 3 additions & 2 deletions s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"encoding/base64"
"encoding/xml"
"fmt"
"github.com/mitchellh/goamz/aws"
"io"
"io/ioutil"
"log"
Expand All @@ -27,6 +26,8 @@ import (
"strconv"
"strings"
"time"

"github.com/mitchellh/goamz/aws"
)

const debug = false
Expand Down Expand Up @@ -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 := ""
Expand Down
28 changes: 19 additions & 9 deletions s3/s3i_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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/", "/")
Expand Down