Commit a8e3f06
committed
test: keep the example client releases reachable
gocritic's exitAfterDefer failed the lint job on the two examples this
branch gave a `defer func() { _ = client.Close() }()`. log.Fatalf calls
os.Exit, which does not unwind the stack, so every Fatalf placed after the
defer would have skipped the close the branch added -- the leak the branch
set out to fix, still leaking on the error path.
Switch those calls to log.Panicf, which runs deferred functions on its way
out. Examples have no *testing.T, so require.NoError and t.Cleanup are not
available here; panicking is what the neighbouring osprom and osotel
examples already do.
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>1 parent 0cf031b commit a8e3f06
2 files changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
0 commit comments