Skip to content

Commit 906dcef

Browse files
authored
chore: remove redundant typeparams for Go 1.17 (#1331)
1 parent a5e5d78 commit 906dcef

File tree

4 files changed

+11
-43
lines changed

4 files changed

+11
-43
lines changed

‎internal/typeparams/typeparams.go‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@ import (
66
"go/ast"
77
)
88

9-
// Enabled reports whether type parameters are enabled in the current build
10-
// environment.
11-
func Enabled() bool {
12-
return enabled
13-
}
14-
159
// ReceiverType returns the named type of the method receiver, sans "*" and type
1610
// parameters, or "invalid-type" if fn.Recv is ill formed.
1711
func ReceiverType(fn *ast.FuncDecl) string {
1812
e := fn.Recv.List[0].Type
1913
if s, ok := e.(*ast.StarExpr); ok {
2014
e = s.X
2115
}
22-
if enabled {
23-
e = unpackIndexExpr(e)
24-
}
16+
e = unpackIndexExpr(e)
2517
if id, ok := e.(*ast.Ident); ok {
2618
return id.Name
2719
}
2820
return "invalid-type"
2921
}
22+
23+
func unpackIndexExpr(e ast.Expr) ast.Expr {
24+
switch e := e.(type) {
25+
case *ast.IndexExpr:
26+
return e.X
27+
case *ast.IndexListExpr:
28+
return e.X
29+
}
30+
return e
31+
}

‎internal/typeparams/typeparams_go117.go‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎internal/typeparams/typeparams_go118.go‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎test/receiver_naming_test.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ package test
33
import (
44
"testing"
55

6-
"github.com/mgechev/revive/internal/typeparams"
76
"github.com/mgechev/revive/lint"
87
"github.com/mgechev/revive/rule"
98
)
109

1110
func TestReceiverNamingTypeParams(t *testing.T) {
12-
if !typeparams.Enabled() {
13-
t.Skip("type parameters are not enabled in the current build environment")
14-
}
1511
testRule(t, "receiver_naming_issue_669", &rule.ReceiverNamingRule{})
1612
}
1713

0 commit comments

Comments
 (0)