@marcel91200 / caddy Mirror · read-only / commits / 25be2f26
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 21:00 UTC

chore: ugh, lint fix... (#7275)

* chore: ugh, lint fix... Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com> * more lint fixes Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com> --------- Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

Mohammed Al Sahaf committed Sep 26, 2025 at 11:14 UTC 25be2f26fc21290692b0442dedbdbbb35eb51526
14 files changed +48 -48
caddy.go
+3 -3
@@ -975,11 +975,11 @@ func Version() (simple, full string) {
975 if CustomVersion != "" {
976 full = CustomVersion
977 simple = CustomVersion
978 - return
978 + return simple, full
979 }
980 full = "unknown"
981 simple = "unknown"
982 - return
982 + return simple, full
983 }
984 // find the Caddy module in the dependency list
985 for _, dep := range bi.Deps {
@@ -1059,7 +1059,7 @@ func Version() (simple, full string) {
1059 }
1060 }
1061
1062 - return
1062 + return simple, full
1063 }
1064
1065 // Event represents something that has happened or is happening.
cmd/packagesfuncs.go
+3 -3
@@ -62,7 +62,7 @@ func splitModule(arg string) (module, version string, err error) {
62 err = fmt.Errorf("module name is required")
63 }
64
65 - return
65 + return module, version, err
66 }
67
68 func cmdAddPackage(fl Flags) (int, error) {
@@ -217,7 +217,7 @@ func getModules() (standard, nonstandard, unknown []moduleInfo, err error) {
217 bi, ok := debug.ReadBuildInfo()
218 if !ok {
219 err = fmt.Errorf("no build info")
220 - return
220 + return standard, nonstandard, unknown, err
221 }
222
223 for _, modID := range caddy.Modules() {
@@ -260,7 +260,7 @@ func getModules() (standard, nonstandard, unknown []moduleInfo, err error) {
260 nonstandard = append(nonstandard, caddyModGoMod)
261 }
262 }
263 - return
263 + return standard, nonstandard, unknown, err
264 }
265
266 func listModules(path string) error {
listen.go
+3 -3
@@ -261,14 +261,14 @@ func (fcpc *fakeClosePacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err e
261 if atomic.LoadInt32(&fcpc.closed) == 1 {
262 if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
263 if err = fcpc.SetReadDeadline(time.Time{}); err != nil {
264 - return
264 + return n, addr, err
265 }
266 }
267 }
268 - return
268 + return n, addr, err
269 }
270
271 - return
271 + return n, addr, err
272 }
273
274 // Close won't close the underlying socket unless there is no more reference, then listenerPool will close it.
listeners.go
+2 -2
@@ -382,7 +382,7 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) {
382 a = afterSlash
383 if IsUnixNetwork(network) || IsFdNetwork(network) {
384 host = a
385 - return
385 + return network, host, port, err
386 }
387 }
388
@@ -402,7 +402,7 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) {
402 err = errors.Join(firstErr, err)
403 }
404
405 - return
405 + return network, host, port, err
406 }
407
408 // JoinNetworkAddress combines network, host, and port into a single
modules/caddyhttp/logging.go
+2 -2
@@ -209,7 +209,7 @@ func errLogValues(err error) (status int, msg string, fields func() []zapcore.Fi
209 zap.String("err_trace", handlerErr.Trace),
210 }
211 }
212 - return
212 + return status, msg, fields
213 }
214 fields = func() []zapcore.Field {
215 return []zapcore.Field{
@@ -218,7 +218,7 @@ func errLogValues(err error) (status int, msg string, fields func() []zapcore.Fi
218 }
219 status = http.StatusInternalServerError
220 msg = err.Error()
221 - return
221 + return status, msg, fields
222 }
223
224 // ExtraLogFields is a list of extra fields to log with every request.
modules/caddyhttp/requestbody/requestbody.go
+1 -1
@@ -116,7 +116,7 @@ func (ew errorWrapper) Read(p []byte) (n int, err error) {
116 if errors.As(err, &mbe) {
117 err = caddyhttp.Error(http.StatusRequestEntityTooLarge, err)
118 }
119 - return
119 + return n, err
120 }
121
122 // Interface guard
modules/caddyhttp/reverseproxy/fastcgi/client.go
+10 -10
@@ -154,13 +154,13 @@ func (c *client) Do(p map[string]string, req io.Reader) (r io.Reader, err error)
154
155 err = writer.writeBeginRequest(uint16(Responder), 0)
156 if err != nil {
157 - return
157 + return r, err
158 }
159
160 writer.recType = Params
161 err = writer.writePairs(p)
162 if err != nil {
163 - return
163 + return r, err
164 }
165
166 writer.recType = Stdin
@@ -176,7 +176,7 @@ func (c *client) Do(p map[string]string, req io.Reader) (r io.Reader, err error)
176 }
177
178 r = &streamReader{c: c}
179 - return
179 + return r, err
180 }
181
182 // clientCloser is a io.ReadCloser. It wraps a io.Reader with a Closer
@@ -213,7 +213,7 @@ func (f clientCloser) Close() error {
213 func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Response, err error) {
214 r, err := c.Do(p, req)
215 if err != nil {
216 - return
216 + return resp, err
217 }
218
219 rb := bufio.NewReader(r)
@@ -223,7 +223,7 @@ func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Respons
223 // Parse the response headers.
224 mimeHeader, err := tp.ReadMIMEHeader()
225 if err != nil && err != io.EOF {
226 - return
226 + return resp, err
227 }
228 resp.Header = http.Header(mimeHeader)
229
@@ -231,7 +231,7 @@ func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Respons
231 statusNumber, statusInfo, statusIsCut := strings.Cut(resp.Header.Get("Status"), " ")
232 resp.StatusCode, err = strconv.Atoi(statusNumber)
233 if err != nil {
234 - return
234 + return resp, err
235 }
236 if statusIsCut {
237 resp.Status = statusInfo
@@ -260,7 +260,7 @@ func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Respons
260 }
261 resp.Body = closer
262
263 - return
263 + return resp, err
264 }
265
266 // Get issues a GET request to the fcgi responder.
@@ -329,7 +329,7 @@ func (c *client) PostFile(p map[string]string, data url.Values, file map[string]
329 for _, v0 := range val {
330 err = writer.WriteField(key, v0)
331 if err != nil {
332 - return
332 + return resp, err
333 }
334 }
335 }
@@ -347,13 +347,13 @@ func (c *client) PostFile(p map[string]string, data url.Values, file map[string]
347 }
348 _, err = io.Copy(part, fd)
349 if err != nil {
350 - return
350 + return resp, err
351 }
352 }
353
354 err = writer.Close()
355 if err != nil {
356 - return
356 + return resp, err
357 }
358
359 return c.Post(p, "POST", bodyType, buf, int64(buf.Len()))
modules/caddyhttp/reverseproxy/fastcgi/client_test.go
+4 -4
@@ -120,7 +120,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
120 conn, err := net.Dial("tcp", ipPort)
121 if err != nil {
122 log.Println("err:", err)
123 - return
123 + return content
124 }
125
126 fcgi := client{rwc: conn, reqID: 1}
@@ -162,7 +162,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
162
163 if err != nil {
164 log.Println("err:", err)
165 - return
165 + return content
166 }
167
168 defer resp.Body.Close()
@@ -176,7 +176,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
176 globalt.Error("Server return failed message")
177 }
178
179 - return
179 + return content
180 }
181
182 func generateRandFile(size int) (p string, m string) {
@@ -206,7 +206,7 @@ func generateRandFile(size int) (p string, m string) {
206 }
207 }
208 m = fmt.Sprintf("%x", h.Sum(nil))
209 - return
209 + return p, m
210 }
211
212 func DisabledTest(t *testing.T) {
modules/caddyhttp/reverseproxy/fastcgi/record.go
+5 -5
@@ -30,23 +30,23 @@ func (rec *record) fill(r io.Reader) (err error) {
30 rec.lr.N = rec.padding
31 rec.lr.R = r
32 if _, err = io.Copy(io.Discard, rec); err != nil {
33 - return
33 + return err
34 }
35
36 if err = binary.Read(r, binary.BigEndian, &rec.h); err != nil {
37 - return
37 + return err
38 }
39 if rec.h.Version != 1 {
40 err = errors.New("fcgi: invalid header version")
41 - return
41 + return err
42 }
43 if rec.h.Type == EndRequest {
44 err = io.EOF
45 - return
45 + return err
46 }
47 rec.lr.N = int64(rec.h.ContentLength)
48 rec.padding = int64(rec.h.PaddingLength)
49 - return
49 + return err
50 }
51
52 func (rec *record) Read(p []byte) (n int, err error) {
modules/caddyhttp/reverseproxy/streaming.go
+3 -3
@@ -588,11 +588,11 @@ func (m *maxLatencyWriter) Write(p []byte) (n int, err error) {
588 m.logger.Debug("flushing immediately")
589 //nolint:errcheck
590 m.flush()
591 - return
591 + return n, err
592 }
593 if m.flushPending {
594 m.logger.Debug("delayed flush already pending")
595 - return
595 + return n, err
596 }
597 if m.t == nil {
598 m.t = time.AfterFunc(m.latency, m.delayedFlush)
@@ -603,7 +603,7 @@ func (m *maxLatencyWriter) Write(p []byte) (n int, err error) {
603 c.Write(zap.Duration("duration", m.latency))
604 }
605 m.flushPending = true
606 - return
606 + return n, err
607 }
608
609 func (m *maxLatencyWriter) delayedFlush() {
modules/caddyhttp/reverseproxy/upstreams.go
+2 -2
@@ -213,12 +213,12 @@ func (su SRVUpstreams) expandedAddr(r *http.Request) (addr, service, proto, name
213 name = repl.ReplaceAll(su.Name, "")
214 if su.Service == "" && su.Proto == "" {
215 addr = name
216 - return
216 + return addr, service, proto, name
217 }
218 service = repl.ReplaceAll(su.Service, "")
219 proto = repl.ReplaceAll(su.Proto, "")
220 addr = su.formattedAddr(service, proto, name)
221 - return
221 + return addr, service, proto, name
222 }
223
224 // formattedAddr the RFC 2782 representation of the SRV domain, in
modules/caddypki/adminapi.go
+3 -3
@@ -220,13 +220,13 @@ func (a *adminAPI) getCAFromAPIRequestPath(r *http.Request) (*CA, error) {
220 func rootAndIntermediatePEM(ca *CA) (root, inter []byte, err error) {
221 root, err = pemEncodeCert(ca.RootCertificate().Raw)
222 if err != nil {
223 - return
223 + return root, inter, err
224 }
225 inter, err = pemEncodeCert(ca.IntermediateCertificate().Raw)
226 if err != nil {
227 - return
227 + return root, inter, err
228 }
229 - return
229 + return root, inter, err
230 }
231
232 // caInfo is the response structure for the CA info API endpoint.
modules/logging/netwriter.go
+4 -4
@@ -172,7 +172,7 @@ func (reconn *redialerConn) Write(b []byte) (n int, err error) {
172 reconn.connMu.RUnlock()
173 if conn != nil {
174 if n, err = conn.Write(b); err == nil {
175 - return
175 + return n, err
176 }
177 }
178
@@ -184,7 +184,7 @@ func (reconn *redialerConn) Write(b []byte) (n int, err error) {
184 // one of them might have already re-dialed by now; try writing again
185 if reconn.Conn != nil {
186 if n, err = reconn.Conn.Write(b); err == nil {
187 - return
187 + return n, err
188 }
189 }
190
@@ -198,7 +198,7 @@ func (reconn *redialerConn) Write(b []byte) (n int, err error) {
198 if err2 != nil {
199 // logger socket still offline; instead of discarding the log, dump it to stderr
200 os.Stderr.Write(b)
201 - return
201 + return n, err
202 }
203 if n, err = conn2.Write(b); err == nil {
204 if reconn.Conn != nil {
@@ -211,7 +211,7 @@ func (reconn *redialerConn) Write(b []byte) (n int, err error) {
211 os.Stderr.Write(b)
212 }
213
214 - return
214 + return n, err
215 }
216
217 func (reconn *redialerConn) dial() (net.Conn, error) {
usagepool.go
+3 -3
@@ -106,7 +106,7 @@ func (up *UsagePool) LoadOrNew(key any, construct Constructor) (value any, loade
106 }
107 upv.Unlock()
108 }
109 - return
109 + return value, loaded, err
110 }
111
112 // LoadOrStore loads the value associated with key from the pool if it
@@ -134,7 +134,7 @@ func (up *UsagePool) LoadOrStore(key, val any) (value any, loaded bool) {
134 up.Unlock()
135 value = val
136 }
137 - return
137 + return value, loaded
138 }
139
140 // Range iterates the pool similarly to how sync.Map.Range() does:
@@ -191,7 +191,7 @@ func (up *UsagePool) Delete(key any) (deleted bool, err error) {
191 upv.value, upv.refs))
192 }
193 }
194 - return
194 + return deleted, err
195 }
196
197 // References returns the number of references (count of usages) to a