Skip to content

Commit abb6741

Browse files
committed
fix more lints
Signed-off-by: Carlos Panato <[email protected]>
1 parent bf2415c commit abb6741

File tree

111 files changed

+1078
-1079
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1078
-1079
lines changed

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ To see the event, let's render it as JSON and log it:
9797

9898
```golang
9999
// Render the event as JSON
100-
eventJson, err := cdevents.AsJsonString(event)
100+
eventJson, err := cdevents.AsJSONString(event)
101101
examples.PanicOnError(err, "failed to marshal the CDEvent")
102102
fmt.Printf("%s", eventJson)
103103
```
@@ -219,15 +219,15 @@ In this case we know that the event is in the v0.4 version format, so we use the
219219
```golang
220220
// Load, unmarshal and validate the event
221221
eventBytes, err := os.ReadFile("changecreated.json")
222-
event, err := cdevents04.NewFromJsonBytes(eventBytes)
222+
event, err := cdevents04.NewFromJSONBytes(eventBytes)
223223

224224
err = cdevent.Validate(event)
225225
if err != nil {
226226
log.Fatalf("cannot validate event %v: %v", event, err)
227227
}
228228

229229
// Print the event
230-
eventJson, err := cdevents.AsJsonString(event)
230+
eventJson, err := cdevents.AsJSONString(event)
231231
examples.PanicOnError(err, "failed to marshal the CDEvent")
232232
fmt.Printf("%s\n\n", eventJson)
233233
```

docs/examples/custom/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
cloudevents "github.com/cloudevents/sdk-go/v2"
1313
)
1414

15-
const customSchemaUri = "https://myregistry.dev/schemas/cdevents/quota-exceeded/0_1_0"
15+
const customSchemaURI = "https://myregistry.dev/schemas/cdevents/quota-exceeded/0_1_0"
1616

1717
type Quota struct {
1818
User string `json:"user"` // The use the quota applies ot
@@ -54,18 +54,18 @@ func main() {
5454

5555
// Set the required subject fields
5656
event.SetSubjectContent(quotaRule123)
57-
event.SetSchemaUri(customSchemaUri)
57+
event.SetSchemaUri(customSchemaURI)
5858

5959
// Print the event
60-
eventJson, err := cdevents.AsJsonString(event)
60+
eventJSON, err := cdevents.AsJSONString(event)
6161
examples.PanicOnError(err, "failed to marshal the CDEvent")
62-
fmt.Printf("%s", eventJson)
62+
fmt.Printf("%s", eventJSON)
6363

6464
// To validate the event, we need to load its custom schema
6565
customSchema, err := os.ReadFile("myregistry-quotaexceeded_schema.json")
6666
examples.PanicOnError(err, "cannot load schema file")
6767

68-
err = cdevents.LoadJsonSchema(customSchemaUri, customSchema)
68+
err = cdevents.LoadJsonSchema(customSchemaURI, customSchema)
6969
examples.PanicOnError(err, "cannot load the custom schema file")
7070

7171
ce, err = cdevents.AsCloudEvent(event)

docs/examples/schemauri/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ func main() {
3030

3131
// Unmarshal the schema to extract the $id. The $id can also be hardcoded as a const
3232
eventAux := &struct {
33-
Id string `json:"$id"`
33+
ID string `json:"$id"`
3434
}{}
3535
err = json.Unmarshal(customSchema, eventAux)
3636
examples.PanicOnError(err, "cannot get $id from schema file")
37-
err = cdevents.LoadJsonSchema(eventAux.Id, customSchema)
37+
err = cdevents.LoadJsonSchema(eventAux.ID, customSchema)
3838
examples.PanicOnError(err, "cannot load the custom schema file")
3939

4040
// Load and unmarshal the event
4141
eventBytes, err := os.ReadFile("changecreated.json")
4242
examples.PanicOnError(err, "cannot load event file")
43-
event, err := cdevents04.NewFromJsonBytes(eventBytes)
43+
event, err := cdevents04.NewFromJSONBytes(eventBytes)
4444
examples.PanicOnError(err, "failed to unmarshal the CDEvent")
4545

4646
// Print the event
47-
eventJson, err := cdevents.AsJsonString(event)
47+
eventJSON, err := cdevents.AsJSONString(event)
4848
examples.PanicOnError(err, "failed to marshal the CDEvent")
49-
fmt.Printf("%s\n\n", eventJson)
49+
fmt.Printf("%s\n\n", eventJSON)
5050

5151
ce, err = cdevents.AsCloudEvent(event)
5252
examples.PanicOnError(err, "failed to create cloudevent")

docs/examples/shared.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
// Copied from https://github.com/eswdd/go-smee/blob/33b0bac1f1ef3abef04c518ddf7552b04edbadd2/smee.go#L54C1-L67C2
99
func CreateSmeeChannel() (*string, error) {
1010
httpClient := http.Client{
11-
CheckRedirect: func(req *http.Request, via []*http.Request) error {
11+
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
1212
return http.ErrUseLastResponse
1313
},
1414
}
@@ -24,6 +24,5 @@ func CreateSmeeChannel() (*string, error) {
2424
func PanicOnError(e error, message string) {
2525
if e != nil {
2626
log.Fatalf(message+", %v", e)
27-
panic(e)
2827
}
2928
}

pkg/api/bindings.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ import (
3131
)
3232

3333
const (
34-
SCHEMA_ID_REGEX = `^https://cdevents.dev/([0-9]\.[0-9])\.[0-9]/schema/([^ ]*)$`
34+
SchemaIDRegex = `^https://cdevents.dev/([0-9]\.[0-9])\.[0-9]/schema/([^ ]*)$`
3535
CustomEventMapKey = "custom"
3636
)
3737

3838
var (
3939
// Validation helper as singleton
4040
validate *validator.Validate
41-
CDEventsSchemaIdRegex = regexp.MustCompile(SCHEMA_ID_REGEX)
41+
CDEventsSchemaIDRegex = regexp.MustCompile(SchemaIDRegex)
4242
)
4343

4444
func init() {
4545
// Register custom validators
4646
validate = validator.New()
4747
validate.RegisterStructValidation(ValidateEventType, CDEventType{})
48-
err := validate.RegisterValidation("uri-reference", ValidateUriReference)
48+
err := validate.RegisterValidation("uri-reference", ValidateURIReference)
4949
panicOnError(err)
5050
err = validate.RegisterValidation("purl", ValidatePurl)
5151
panicOnError(err)
@@ -84,7 +84,7 @@ func ValidateEventType(sl validator.StructLevel) {
8484
}
8585
}
8686

87-
func ValidateUriReference(fl validator.FieldLevel) bool {
87+
func ValidateURIReference(fl validator.FieldLevel) bool {
8888
_, err := url.Parse(fl.Field().String())
8989
return err == nil
9090
}
@@ -119,8 +119,8 @@ func AsCloudEvent(event CDEventReader) (*cloudevents.Event, error) {
119119
return &ce, err
120120
}
121121

122-
// AsJsonBytes renders a CDEvent as a JSON string
123-
func AsJsonBytes(event CDEventReader) ([]byte, error) {
122+
// AsJSONBytes renders a CDEvent as a JSON string
123+
func AsJSONBytes(event CDEventReader) ([]byte, error) {
124124
if event == nil {
125125
return nil, nil
126126
}
@@ -131,9 +131,9 @@ func AsJsonBytes(event CDEventReader) ([]byte, error) {
131131
return jsonBytes, nil
132132
}
133133

134-
// AsJsonString renders a CDEvent as a JSON string
135-
func AsJsonString(event CDEventReader) (string, error) {
136-
jsonBytes, err := AsJsonBytes(event)
134+
// AsJSONString renders a CDEvent as a JSON string
135+
func AsJSONString(event CDEventReader) (string, error) {
136+
jsonBytes, err := AsJSONBytes(event)
137137
if err != nil {
138138
return "", err
139139
}
@@ -147,7 +147,7 @@ func Validate(event CDEventReader) error {
147147
return err
148148
}
149149
var v interface{}
150-
jsonString, err := AsJsonString(event)
150+
jsonString, err := AsJSONString(event)
151151
if err != nil {
152152
return fmt.Errorf("cannot render the event %s as json %w", event, err)
153153
}
@@ -181,11 +181,11 @@ func Validate(event CDEventReader) error {
181181
return nil
182182
}
183183

184-
// NewFromJsonBytesContext[ContextType] builds a new CDEventReader from a JSON string as []bytes
184+
// NewFromJSONBytesContext[ContextType] builds a new CDEventReader from a JSON string as []bytes
185185
// This works by unmarshalling the context first, extracting the event type and using
186186
// that to unmarshal the rest of the event into the correct object.
187187
// `ContextType` defines the type of Context that can be used to unmarshal the event.
188-
func NewFromJsonBytesContext[CDEventType CDEvent](event []byte, cdeventsMap map[string]CDEventType) (CDEventType, error) {
188+
func NewFromJSONBytesContext[CDEventType CDEvent](event []byte, cdeventsMap map[string]CDEventType) (CDEventType, error) {
189189
eventAux := &struct {
190190
Context Context `json:"context"`
191191
}{}

0 commit comments

Comments
 (0)