Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace empty interface declaration with "any" keyword #24

Merged
merged 4 commits into from
Oct 4, 2022
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: install Go
uses: actions/setup-go@v3
with:
go-version: 1.17.x
go-version: 1.19.x

- name: get modules
run: go mod vendor
Expand All @@ -28,7 +28,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.2.0
with:
version: v1.44
version: v1.49

- name: run tests
run: make test
4 changes: 2 additions & 2 deletions examples/simple-http-server-funcs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {

func newPing(handle *githubevents.EventHandler) {
handle.OnBeforeAny(
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
fmt.Println("ping!")
return nil
},
Expand All @@ -36,7 +36,7 @@ func newPing(handle *githubevents.EventHandler) {

func newPong(handle *githubevents.EventHandler) {
handle.OnBeforeAny(
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
fmt.Println("pong!")
return nil
},
Expand Down
8 changes: 4 additions & 4 deletions gen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ func main() {
}
}

func ExecuteWebhookEventTemplate(file string, data interface{}) error {
func ExecuteWebhookEventTemplate(file string, data any) error {
err := ExecuteTemplate(file+".go", webhookEventTemplate, data)
if err != nil {
return err
}
return nil
}

func ExecuteWebhookEventTypesTemplate(file string, data interface{}) error {
func ExecuteWebhookEventTypesTemplate(file string, data any) error {
err := ExecuteTemplate(file+".go", webhookTypesTemplate, data)
if err != nil {
return err
Expand All @@ -75,7 +75,7 @@ func ExecuteWebhookEventTypesTemplate(file string, data interface{}) error {
}

// ExecuteWebhookEventTypesTemplate renders the named template and writes to io.Writer wr.
func ExecuteTemplate(file string, tmpl string, data interface{}) error {
func ExecuteTemplate(file string, tmpl string, data any) error {
wr := os.Stdout
if output := file; output != "" {
wri, err := os.Create(output)
Expand Down Expand Up @@ -107,7 +107,7 @@ func ExecuteTemplate(file string, tmpl string, data interface{}) error {
}

// ExecuteMarkdownTemplate renders the named template and writes to io.Writer wr.
func ExecuteMarkdownTemplate(file string, tmpl string, data interface{}) error {
func ExecuteMarkdownTemplate(file string, tmpl string, data any) error {
wr := os.Stdout
buf := new(bytes.Buffer)
t, err := template.New("").Parse(tmpl)
Expand Down
16 changes: 8 additions & 8 deletions gen/template_webhook_event_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,15 @@ func Test{{ $webhook.Event }}(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -440,15 +440,15 @@ func Test{{ $webhook.Event }}(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -484,15 +484,15 @@ func Test{{ $webhook.Event }}(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -528,15 +528,15 @@ func Test{{ $webhook.Event }}(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down
40 changes: 20 additions & 20 deletions githubevents/events_branch_protection_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,15 +756,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -796,15 +796,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -840,15 +840,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -884,15 +884,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -929,15 +929,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -973,15 +973,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -1017,15 +1017,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -1062,15 +1062,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -1106,15 +1106,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down Expand Up @@ -1150,15 +1150,15 @@ func TestBranchProtectionRuleEvent(t *testing.T) {
WebhookSecret: "fake",
onBeforeAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onBeforeAny called")
return nil
},
},
},
onAfterAny: map[string][]EventHandleFunc{
EventAnyAction: {
func(deliveryID string, eventName string, event interface{}) error {
func(deliveryID string, eventName string, event any) error {
t.Log("onAfterAny called")
return nil
},
Expand Down
Loading