github.com/prysmaticlabs/prysm@v1.4.4/tools/analyzers/shadowpredecl/testdata/shadow.go (about) 1 package testdata 2 3 type len struct { // want "Type 'len' shadows a predeclared identifier with the same name. Choose another name." 4 5 } 6 7 type int interface { // want "Type 'int' shadows a predeclared identifier with the same name. Choose another name." 8 9 } 10 11 // Struct -- 12 func Struct() { 13 type error struct { // want "Type 'error' shadows a predeclared identifier with the same name. Choose another name." 14 int int // No diagnostic because the name is always referenced indirectly through a struct variable. 15 } 16 } 17 18 // TypeAlias -- 19 func TypeAlias() { 20 type error string // want "Type 'error' shadows a predeclared identifier with the same name. Choose another name." 21 } 22 23 // UninitializedVarAndAssignments -- 24 func UninitializedVarAndAssignments() { 25 var error int // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name." 26 error = 1 // No diagnostic because the original declaration already triggered one. 27 if error == 0 { 28 } 29 } 30 31 // InitializedVar -- 32 func InitializedVar() { 33 error := 0 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name." 34 if error == 0 { 35 } 36 } 37 38 // FirstInVarList -- 39 func FirstInVarList() { 40 error, x := 0, 1 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name." 41 if error == x { 42 } 43 } 44 45 // SecondInVarList -- 46 func SecondInVarList() { 47 x, error := 0, 1 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name." 48 if error == x { 49 } 50 } 51 52 // Const -- 53 func Const() { 54 const error = 0 // want "Identifier 'error' shadows a predeclared identifier with the same name. Choose another name." 55 } 56 57 // Test function and parameter names. 58 func error(len int) { // want "Function 'error' shadows a predeclared identifier with the same name. Choose another name." "Identifier 'len' shadows a predeclared identifier with the same name. Choose another name." 59 if len == 0 { 60 } 61 62 // Test parameter in a new line. 63 f := func( 64 int string) { // want "Identifier 'int' shadows a predeclared identifier with the same name. Choose another name." 65 } 66 67 f("") 68 } 69 70 type receiver struct { 71 } 72 73 // Receiver is a test receiver function. 74 func (s *receiver) Receiver(len int) { 75 76 }