Skip to content

Commit 476be7d

Browse files
robertoduessmannbmoffatt
authored andcommitted
Improvements to golint (#243)
* First improvements to golint * Add comment to methods and structs as suggested by golint * Improvements to lint * Improve more some golint * Fix typo regarding IAMPolicyStatement
1 parent e8b9e00 commit 476be7d

11 files changed

+34
-4
lines changed

events/apigw.go

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ type APIGatewayCustomAuthorizerPolicy struct {
168168
Statement []IAMPolicyStatement
169169
}
170170

171+
// IAMPolicyStatement represents one statement from IAM policy with action, effect and resource
171172
type IAMPolicyStatement struct {
172173
Action []string
173174
Effect string

events/cloudwatch_logs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type CloudwatchLogsData struct {
4747
LogEvents []CloudwatchLogsLogEvent `json:"logEvents"`
4848
}
4949

50-
// LogEvent represents a log entry from cloudwatch logs
50+
// CloudwatchLogsLogEvent represents a log entry from cloudwatch logs
5151
type CloudwatchLogsLogEvent struct {
5252
ID string `json:"id"`
5353
Timestamp int64 `json:"timestamp"`

events/code_commit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (t *CodeCommitEventTime) UnmarshalJSON(data []byte) error {
4343
return err
4444
}
4545

46-
// represents a CodeCommit record
46+
// CodeCommitRecord represents a CodeCommit record
4747
type CodeCommitRecord struct {
4848
EventID string `json:"eventId"`
4949
EventVersion string `json:"eventVersion"`

events/codebuild.go

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const (
1111
CodeBuildPhaseChangeDetailType = "CodeBuild Build Phase Change"
1212
)
1313

14+
// CodeBuildPhaseStatus represents the status of code build phase (i.e. failed, in progress)
1415
type CodeBuildPhaseStatus string
1516

1617
const (
@@ -23,6 +24,7 @@ const (
2324
CodeBuildPhaseStatusTimedOut = "TIMED_OUT"
2425
)
2526

27+
// CodeBuildPhaseType represents the type of the code build phase (i.e. submitted, install)
2628
type CodeBuildPhaseType string
2729

2830
const (
@@ -73,6 +75,7 @@ type CodeBuildEvent struct {
7375
Detail CodeBuildEventDetail `json:"detail"`
7476
}
7577

78+
// CodeBuildEventDetail represents the all details related to the code build event
7679
type CodeBuildEventDetail struct {
7780
BuildStatus CodeBuildPhaseStatus `json:"build-status"`
7881
ProjectName string `json:"project-name"`
@@ -90,6 +93,7 @@ type CodeBuildEventDetail struct {
9093
CompletedPhaseEnd CodeBuildTime `json:"completed-phase-end"`
9194
}
9295

96+
//CodeBuildEventAdditionalInformation represents additional informations to the code build event
9397
type CodeBuildEventAdditionalInformation struct {
9498
Artifact CodeBuildArtifact `json:"artifact"`
9599

@@ -110,12 +114,14 @@ type CodeBuildEventAdditionalInformation struct {
110114
Phases []CodeBuildPhase `json:"phases"`
111115
}
112116

117+
// CodeBuildArtifact represents the artifact provided to build
113118
type CodeBuildArtifact struct {
114119
MD5Sum string `json:"md5sum"`
115120
SHA256Sum string `json:"sha256sum"`
116121
Location string `json:"location"`
117122
}
118123

124+
// CodeBuildEnvironment represents the environment for a build
119125
type CodeBuildEnvironment struct {
120126
Image string `json:"image"`
121127
PrivilegedMode bool `json:"privileged-mode"`
@@ -124,6 +130,7 @@ type CodeBuildEnvironment struct {
124130
EnvironmentVariables []CodeBuildEnvironmentVariable `json:"environment-variables"`
125131
}
126132

133+
// CodeBuildEnvironmentVariable encapsulate environment variables for the code build
127134
type CodeBuildEnvironmentVariable struct {
128135
// Name is the name of the environment variable.
129136
Name string `json:"name"`
@@ -135,17 +142,20 @@ type CodeBuildEnvironmentVariable struct {
135142
Value string `json:"value"`
136143
}
137144

145+
// CodeBuildSource represent the code source will be build
138146
type CodeBuildSource struct {
139147
Location string `json:"location"`
140148
Type string `json:"type"`
141149
}
142150

151+
// CodeBuildLogs gives the log details of a code build
143152
type CodeBuildLogs struct {
144153
GroupName string `json:"group-name"`
145154
StreamName string `json:"stream-name"`
146155
DeepLink string `json:"deep-link"`
147156
}
148157

158+
// CodeBuildPhase represents the phase of a build and its details
149159
type CodeBuildPhase struct {
150160
PhaseContext []interface{} `json:"phase-context"`
151161

@@ -160,14 +170,17 @@ type CodeBuildPhase struct {
160170
PhaseStatus CodeBuildPhaseStatus `json:"phase-status"`
161171
}
162172

173+
// CodeBuildTime represents the time of the build
163174
type CodeBuildTime time.Time
164175

165176
const codeBuildTimeFormat = "Jan 2, 2006 3:04:05 PM"
166177

178+
// MarshalJSON converts a given CodeBuildTime to json
167179
func (t CodeBuildTime) MarshalJSON() ([]byte, error) {
168180
return json.Marshal(time.Time(t).Format(codeBuildTimeFormat))
169181
}
170182

183+
// UnmarshalJSON converts a given json to a CodeBuildTime
171184
func (t *CodeBuildTime) UnmarshalJSON(data []byte) error {
172185
var s string
173186
if err := json.Unmarshal(data, &s); err != nil {

events/duration.go

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
type DurationSeconds time.Duration
1010

11+
// UnmarshalJSON converts a given json to a DurationSeconds
1112
func (duration *DurationSeconds) UnmarshalJSON(data []byte) error {
1213
var seconds float64
1314
if err := json.Unmarshal(data, &seconds); err != nil {
@@ -18,13 +19,15 @@ func (duration *DurationSeconds) UnmarshalJSON(data []byte) error {
1819
return nil
1920
}
2021

22+
// MarshalJSON converts a given DurationSeconds to json
2123
func (duration DurationSeconds) MarshalJSON() ([]byte, error) {
2224
seconds := time.Duration(duration).Seconds()
2325
return json.Marshal(int64(math.Ceil(seconds)))
2426
}
2527

2628
type DurationMinutes time.Duration
2729

30+
// UnmarshalJSON converts a given json to a DurationMinutes
2831
func (duration *DurationMinutes) UnmarshalJSON(data []byte) error {
2932
var minutes float64
3033
if err := json.Unmarshal(data, &minutes); err != nil {
@@ -35,6 +38,7 @@ func (duration *DurationMinutes) UnmarshalJSON(data []byte) error {
3538
return nil
3639
}
3740

41+
// MarshalJSON converts a given DurationMinutes to json
3842
func (duration DurationMinutes) MarshalJSON() ([]byte, error) {
3943
minutes := time.Duration(duration).Minutes()
4044
return json.Marshal(int64(math.Ceil(minutes)))

events/dynamodb.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type DynamoDBUserIdentity struct {
6363
PrincipalID string `json:"principalId"`
6464
}
6565

66-
// A description of a single data modification that was performed on an item
66+
// DynamoDBStreamRecord represents a description of a single data modification that was performed on an item
6767
// in a DynamoDB table.
6868
type DynamoDBStreamRecord struct {
6969

events/s3.go

+2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import (
66
"time"
77
)
88

9+
// S3Event which wrap an array of S3EventRecord
910
type S3Event struct {
1011
Records []S3EventRecord `json:"Records"`
1112
}
1213

14+
// S3EventRecord which wrap record data
1315
type S3EventRecord struct {
1416
EventVersion string `json:"eventVersion"`
1517
EventSource string `json:"eventSource"`

events/s3_batch_job.go

+5
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,36 @@
22

33
package events
44

5+
// S3BatchJobEvent encapsulates the detail of a s3 batch job
56
type S3BatchJobEvent struct {
67
InvocationSchemaVersion string `json:"invocationSchemaVersion"`
78
InvocationID string `json:"invocationId"`
89
Job S3BatchJob `json:"job"`
910
Tasks []S3BatchJobTask `json:"tasks"`
1011
}
1112

13+
// S3BatchJob whichs have the job id
1214
type S3BatchJob struct {
1315
ID string `json:"id"`
1416
}
1517

18+
// S3BatchJobTask represents one task in the s3 batch job and have all task details
1619
type S3BatchJobTask struct {
1720
TaskID string `json:"taskId"`
1821
S3Key string `json:"s3Key"`
1922
S3VersionID string `json:"s3VersionId"`
2023
S3BucketARN string `json:"s3BucketArn"`
2124
}
2225

26+
// S3BatchJobResponse is the response of a iven s3 batch job with the results
2327
type S3BatchJobResponse struct {
2428
InvocationSchemaVersion string `json:"invocationSchemaVersion"`
2529
TreatMissingKeysAs string `json:"treatMissingKeysAs"`
2630
InvocationID string `json:"invocationId"`
2731
Results []S3BatchJobResult `json:"results"`
2832
}
2933

34+
// S3BatchJobResult represents the result of a given task
3035
type S3BatchJobResult struct {
3136
TaskID string `json:"taskId"`
3237
ResultCode string `json:"resultCode"`

events/test/jsoncompare.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/stretchr/testify/assert"
99
)
1010

11-
// Asserts two JSON files are semantically equal
11+
// AssertJsonsEqual asserts two JSON files are semantically equal
1212
// (ignores white-space and attribute order)
1313
func AssertJsonsEqual(t *testing.T, expectedJson []byte, actualJson []byte) {
1414
assert.JSONEq(t, string(expectedJson), string(actualJson))

events/test/readjson.go

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66
)
77

8+
// ReadJSONFromFile reads a given input file to JSON
89
func ReadJSONFromFile(t *testing.T, inputFile string) []byte {
910
inputJSON, err := ioutil.ReadFile(inputFile)
1011
if err != nil {

lambda/function.go

+4
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@ import (
1212
"github.com/aws/aws-lambda-go/lambdacontext"
1313
)
1414

15+
// Function struct which wrap the Handler
1516
type Function struct {
1617
handler Handler
1718
}
1819

20+
// NewFunction which creates a Function with a given Handler
1921
func NewFunction(handler Handler) *Function {
2022
return &Function{handler: handler}
2123
}
2224

25+
// Ping method which given a PingRequest and a PingResponse parses the PingResponse
2326
func (fn *Function) Ping(req *messages.PingRequest, response *messages.PingResponse) error {
2427
*response = messages.PingResponse{}
2528
return nil
2629
}
2730

31+
// Invoke method try to perform a command given an InvokeRequest and an InvokeResponse
2832
func (fn *Function) Invoke(req *messages.InvokeRequest, response *messages.InvokeResponse) error {
2933
defer func() {
3034
if err := recover(); err != nil {

0 commit comments

Comments
 (0)