github.com/nozzle/golangci-lint@v1.49.0-nz3/test/testdata/exhaustivestruct_custom.go (about) 1 //golangcitest:args -Eexhaustivestruct --internal-cmd-test 2 //golangcitest:config_path testdata/configs/exhaustivestruct.yml 3 package testdata 4 5 import "time" 6 7 type ExhaustiveStructCustom struct { 8 A string 9 B int 10 c bool // private field inside the same package are not ignored 11 D float64 12 E time.Time 13 } 14 15 func exhaustiveStructCustom() { 16 // pass 17 _ = ExhaustiveStructCustom{ 18 A: "a", 19 B: 0, 20 c: false, 21 D: 1.0, 22 E: time.Now(), 23 } 24 25 // fail 26 _ = ExhaustiveStructCustom{ // want "B is missing in ExhaustiveStructCustom" 27 A: "a", 28 c: false, 29 D: 1.0, 30 E: time.Now(), 31 } 32 33 // failMultiple 34 _ = ExhaustiveStructCustom{ // want "B, D are missing in ExhaustiveStructCustom" 35 A: "a", 36 c: false, 37 E: time.Now(), 38 } 39 40 // failPrivate 41 _ = ExhaustiveStructCustom{ // want "c is missing in ExhaustiveStructCustom" 42 A: "a", 43 B: 0, 44 D: 1.0, 45 E: time.Now(), 46 } 47 48 } 49 50 type ExhaustiveStructCustom1 struct { 51 A string 52 B int 53 c bool // private field inside the same package are not ignored 54 D float64 55 E time.Time 56 } 57 58 func exhaustiveStructCustom1() { 59 _ = ExhaustiveStructCustom1{ 60 A: "a", 61 B: 0, 62 c: false, 63 D: 1.0, 64 E: time.Now(), 65 } 66 67 _ = ExhaustiveStructCustom1{ 68 A: "a", 69 c: false, 70 D: 1.0, 71 E: time.Now(), 72 } 73 74 _ = ExhaustiveStructCustom1{ 75 A: "a", 76 c: false, 77 E: time.Now(), 78 } 79 80 _ = ExhaustiveStructCustom1{ 81 A: "a", 82 B: 0, 83 D: 1.0, 84 E: time.Now(), 85 } 86 } 87 88 type ExhaustiveStructCustom2 struct { 89 A string 90 B int 91 c bool // private field inside the same package are not ignored 92 D float64 93 E time.Time 94 } 95 96 func exhaustiveStructCustom2() { 97 // pass 98 _ = ExhaustiveStructCustom2{ 99 A: "a", 100 B: 0, 101 c: false, 102 D: 1.0, 103 E: time.Now(), 104 } 105 106 // fail 107 _ = ExhaustiveStructCustom2{ // want "B is missing in ExhaustiveStructCustom2" 108 A: "a", 109 c: false, 110 D: 1.0, 111 E: time.Now(), 112 } 113 114 // failMultiple 115 _ = ExhaustiveStructCustom2{ // want "B, D are missing in ExhaustiveStructCustom2" 116 A: "a", 117 c: false, 118 E: time.Now(), 119 } 120 121 // failPrivate 122 _ = ExhaustiveStructCustom2{ // want "c is missing in ExhaustiveStructCustom2" 123 A: "a", 124 B: 0, 125 D: 1.0, 126 E: time.Now(), 127 } 128 129 }