Debian Codegraph @

go/analysis/passes/shadow/doc.go

raw symbols SCIP
1 // Copyright 2023 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package shadow defines an Analyzer that checks for shadowed variables.
6 //
7 // # Analyzer shadow
8 //
9 // shadow: check for possible unintended shadowing of variables
10 //
11 // This analyzer check for shadowed variables.
12 // A shadowed variable is a variable declared in an inner scope
13 // with the same name and type as a variable in an outer scope,
14 // and where the outer variable is mentioned after the inner one
15 // is declared.
16 //
17 // (This definition can be refined; the module generates too many
18 // false positives and is not yet enabled by default.)
19 //
20 // For example:
21 //
22 // func BadRead(f *os.File, buf []byte) error {
23 // var err error
24 // for {
25 // n, err := f.Read(buf) // shadows the function variable 'err'
26 // if err != nil {
27 // break // causes return of wrong value
28 // }
29 // foo(buf)
30 // }
31 // return err
32 // }
33 package shadow