From 50fc802840241c3915cd2866186c55e42e9fc580 Mon Sep 17 00:00:00 2001 From: Morgan Gangwere <470584+indrora@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:16:58 -0800 Subject: [PATCH] s1034: Add explanatory example --- simple/s1034/s1034.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/simple/s1034/s1034.go b/simple/s1034/s1034.go index 9eb953127..7e6fcebc0 100644 --- a/simple/s1034/s1034.go +++ b/simple/s1034/s1034.go @@ -24,6 +24,28 @@ var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{ Doc: &lint.RawDocumentation{ Title: `Use result of type assertion to simplify cases`, Since: "2019.2", + Text: ` +When using the type of a variable in a switch statement, the type of the variable is inferred from the case condition. + +The following + + switch o.(type) { + case string: + a = o.(string) + case int: + b = o.(int) + } + +can be simplified as + + switch o.(type) { + case string: + a = o + case int: + b = o + } + +as the type of o has been established within the context of the case statement.`, MergeIf: lint.MergeIfAny, }, })