We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 31e1ee5 commit 50fc802Copy full SHA for 50fc802
simple/s1034/s1034.go
@@ -24,6 +24,28 @@ var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
24
Doc: &lint.RawDocumentation{
25
Title: `Use result of type assertion to simplify cases`,
26
Since: "2019.2",
27
+ Text: `
28
+When using the type of a variable in a switch statement, the type of the variable is inferred from the case condition.
29
+
30
+The following
31
32
+ switch o.(type) {
33
+ case string:
34
+ a = o.(string)
35
+ case int:
36
+ b = o.(int)
37
+ }
38
39
+can be simplified as
40
41
42
43
+ a = o
44
45
+ b = o
46
47
48
+as the type of o has been established within the context of the case statement.`,
49
MergeIf: lint.MergeIfAny,
50
},
51
})
0 commit comments