Skip to content

Commit e7b076e

Browse files
philtaybmoffatt
authored andcommitted
Linter pass (#203)
1 parent 4b515f5 commit e7b076e

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

cmd/build-lambda-zip/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func main() {
2525

2626
app.Action = func(c *cli.Context) error {
2727
if !c.Args().Present() {
28-
return errors.New("No input provided")
28+
return errors.New("no input provided")
2929
}
3030

3131
inputExe := c.Args().First()
@@ -35,7 +35,7 @@ func main() {
3535
}
3636

3737
if err := compressExeAndArgs(outputZip, inputExe, c.Args().Tail()); err != nil {
38-
return fmt.Errorf("Failed to compress file: %v", err)
38+
return fmt.Errorf("failed to compress file: %v", err)
3939
}
4040
return nil
4141
}
@@ -71,7 +71,6 @@ func compressExeAndArgs(outZipPath string, exePath string, args []string) error
7171
if closeErr != nil {
7272
fmt.Fprintf(os.Stderr, "Failed to close zip file: %v\n", closeErr)
7373
}
74-
return
7574
}()
7675

7776
zipWriter := zip.NewWriter(zipFile)

events/attributevalue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ func Test_DynamoDBAttributeValue_NewAttribute(t *testing.T) {
259259
assert.Equal(t, true, av.Boolean())
260260
}
261261
{
262-
av := NewBinarySetAttribute([][]byte{[]byte{1, 2, 3}})
262+
av := NewBinarySetAttribute([][]byte{{1, 2, 3}})
263263
assert.Equal(t, DataTypeBinarySet, av.DataType())
264-
assert.Equal(t, [][]byte{[]byte{1, 2, 3}}, av.BinarySet())
264+
assert.Equal(t, [][]byte{{1, 2, 3}}, av.BinarySet())
265265
}
266266
{
267267
av := NewListAttribute([]DynamoDBAttributeValue{

events/cloudwatch_logs.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ func (c CloudwatchLogsRawData) Parse() (d CloudwatchLogsData, err error) {
2626
}
2727

2828
zr, err := gzip.NewReader(bytes.NewBuffer(data))
29-
defer zr.Close()
3029
if err != nil {
3130
return
3231
}
32+
defer zr.Close()
3333

34-
buf := &bytes.Buffer{}
35-
buf.ReadFrom(zr)
34+
dec := json.NewDecoder(zr)
35+
err = dec.Decode(&d)
3636

37-
err = json.Unmarshal(buf.Bytes(), &d)
3837
return
3938
}
4039

events/cognito.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type CognitoEventUserPoolsPostConfirmation struct {
3737
}
3838

3939
// CognitoEventUserPoolsPreTokenGen is sent by AWS Cognito User Pools when a user attempts to retrieve
40-
// credentials, allowing a Lambda to perform insert, supress or override claims
40+
// credentials, allowing a Lambda to perform insert, suppress or override claims
4141
type CognitoEventUserPoolsPreTokenGen struct {
4242
CognitoEventUserPoolsHeader
4343
Request CognitoEventUserPoolsPreTokenGenRequest `json:"request"`
@@ -133,7 +133,7 @@ type CognitoEventUserPoolsMigrateUserResponse struct {
133133
ForceAliasCreation bool `json:"forceAliasCreation"`
134134
}
135135

136-
// ClaimsOverrideDetails allows lambda to add, supress or override claims in the token
136+
// ClaimsOverrideDetails allows lambda to add, suppress or override claims in the token
137137
type ClaimsOverrideDetails struct {
138138
GroupOverrideDetails GroupConfiguration `json:"groupOverrideDetails"`
139139
ClaimsToAddOrOverride map[string]string `json:"claimsToAddOrOverride"`

events/firehose_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ func testFirehoseResponseMarshaling(t *testing.T) {
2020
}
2121

2222
func testMarshaling(t *testing.T, jsonFile string) {
23-
2423
// 1. read JSON from file
2524
inputJson := test.ReadJSONFromFile(t, jsonFile)
2625

@@ -41,7 +40,6 @@ func testMarshaling(t *testing.T, jsonFile string) {
4140
}
4241

4342
func TestSampleTransformation(t *testing.T) {
44-
4543
inputJson := test.ReadJSONFromFile(t, "./testdata/kinesis-firehose-event.json")
4644

4745
// de-serialize into Go object

lambda/handler.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,20 @@ func validateArguments(handler reflect.Type) (bool, error) {
5858

5959
func validateReturns(handler reflect.Type) error {
6060
errorType := reflect.TypeOf((*error)(nil)).Elem()
61-
if handler.NumOut() > 2 {
61+
62+
switch n := handler.NumOut(); {
63+
case n > 2:
6264
return fmt.Errorf("handler may not return more than two values")
63-
} else if handler.NumOut() > 1 {
65+
case n > 1:
6466
if !handler.Out(1).Implements(errorType) {
6567
return fmt.Errorf("handler returns two values, but the second does not implement error")
6668
}
67-
} else if handler.NumOut() == 1 {
69+
case n == 1:
6870
if !handler.Out(0).Implements(errorType) {
6971
return fmt.Errorf("handler returns a single value, but it does not implement error")
7072
}
7173
}
74+
7275
return nil
7376
}
7477

0 commit comments

Comments
 (0)