Commit 2a344e2
authored
chore: simplify, modernize (Go 1.26), update deps (#137)
* chore: simplify, modernize (Go 1.26), update deps
- Remove dead `p.log = new(slog.Logger)` alloc (plugin.go)
- Extract `prepareCmd` helper — eliminates the three identical
command-parse switches in plugin.go / internal.go / init.go
- `slices.Clone` replaces manual make+copy for env slices (internal.go)
- `strings.Cut` replaces `strings.Split`+len check in initFactory (internal.go)
- Merge `case unix: / case tcp:` into `case unix, tcp:` (internal.go)
- Concat replaces `fmt.Sprintf` for simple key=value env strings (plugin.go, internal.go, init.go)
- `os.ExpandEnv` replaces `os.Expand(v, os.Getenv)` (plugin.go, init.go)
- `strconv.Atoi` replaces `strconv.ParseInt(..., 10, 32)` (plugin.go)
- Deduplicate `user.Lookup` via new `userInfo()` helper; UID/GID
delegate to it (plugin.go)
- Fix error log in GID using `cfg.Group` instead of `cfg.User` (plugin.go)
- Move `time.NewTimer` after `cmd.Start()` to avoid goroutine leak
on Start failure; add `defer timer.Stop()` (init.go)
- Fix env ordering in `createProcess`: OS env first, config env
appended, matching the main worker path so user config takes
precedence over inherited OS env (init.go)
- Update tests/ dependencies
* fix: use strings.Fields to collapse whitespace in prepareCmd
strings.Split on a single space produces empty-string arguments when
the command string contains multiple consecutive spaces (e.g. "php app.php"
→ ["php", "", "app.php"]). strings.Fields trims leading/trailing whitespace
and collapses runs of whitespace, matching user intent.4 files changed
Lines changed: 65 additions & 105 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | | - | |
42 | | - | |
43 | 40 | | |
44 | 41 | | |
45 | 42 | | |
46 | 43 | | |
47 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 86 | + | |
102 | 87 | | |
| 88 | + | |
103 | 89 | | |
104 | | - | |
| 90 | + | |
105 | 91 | | |
106 | 92 | | |
107 | 93 | | |
108 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
109 | 98 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 99 | + | |
| 100 | + | |
114 | 101 | | |
115 | 102 | | |
116 | | - | |
117 | | - | |
118 | 103 | | |
119 | 104 | | |
120 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
23 | 34 | | |
24 | 35 | | |
25 | 36 | | |
| |||
32 | 43 | | |
33 | 44 | | |
34 | 45 | | |
35 | | - | |
36 | | - | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 49 | + | |
| 50 | + | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
| |||
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
59 | | - | |
| 67 | + | |
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
66 | 74 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 75 | + | |
81 | 76 | | |
| 77 | + | |
82 | 78 | | |
83 | 79 | | |
84 | 80 | | |
85 | 81 | | |
86 | 82 | | |
87 | 83 | | |
88 | 84 | | |
89 | | - | |
90 | | - | |
| 85 | + | |
91 | 86 | | |
92 | 87 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 88 | + | |
| 89 | + | |
97 | 90 | | |
98 | 91 | | |
99 | 92 | | |
| |||
117 | 110 | | |
118 | 111 | | |
119 | 112 | | |
120 | | - | |
121 | | - | |
| 113 | + | |
| 114 | + | |
122 | 115 | | |
123 | 116 | | |
124 | 117 | | |
| |||
127 | 120 | | |
128 | 121 | | |
129 | 122 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 123 | + | |
| 124 | + | |
135 | 125 | | |
136 | 126 | | |
137 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
56 | 54 | | |
57 | 55 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 56 | + | |
69 | 57 | | |
70 | | - | |
| 58 | + | |
71 | 59 | | |
72 | | - | |
| 60 | + | |
73 | 61 | | |
74 | 62 | | |
75 | 63 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 64 | + | |
| 65 | + | |
80 | 66 | | |
81 | 67 | | |
82 | | - | |
| 68 | + | |
83 | 69 | | |
84 | 70 | | |
85 | 71 | | |
| |||
160 | 146 | | |
161 | 147 | | |
162 | 148 | | |
163 | | - | |
164 | | - | |
| 149 | + | |
| 150 | + | |
165 | 151 | | |
166 | | - | |
| 152 | + | |
167 | 153 | | |
168 | 154 | | |
169 | 155 | | |
170 | 156 | | |
171 | 157 | | |
172 | | - | |
| 158 | + | |
173 | 159 | | |
174 | 160 | | |
175 | | - | |
| 161 | + | |
176 | 162 | | |
177 | 163 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
| 164 | + | |
188 | 165 | | |
189 | 166 | | |
190 | | - | |
| 167 | + | |
191 | 168 | | |
192 | | - | |
193 | | - | |
| 169 | + | |
| 170 | + | |
194 | 171 | | |
195 | 172 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 173 | + | |
| 174 | + | |
201 | 175 | | |
202 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
203 | 186 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
160 | 161 | | |
| 162 | + | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
| |||
0 commit comments