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>
This commit is contained in:
Mohammed Al Sahaf 2025-09-26 11:14:48 +04:00 committed by GitHub
parent 0c8798fce3
commit 25be2f26fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 48 additions and 48 deletions

View file

@ -975,11 +975,11 @@ func Version() (simple, full string) {
if CustomVersion != "" { if CustomVersion != "" {
full = CustomVersion full = CustomVersion
simple = CustomVersion simple = CustomVersion
return return simple, full
} }
full = "unknown" full = "unknown"
simple = "unknown" simple = "unknown"
return return simple, full
} }
// find the Caddy module in the dependency list // find the Caddy module in the dependency list
for _, dep := range bi.Deps { for _, dep := range bi.Deps {
@ -1059,7 +1059,7 @@ func Version() (simple, full string) {
} }
} }
return return simple, full
} }
// Event represents something that has happened or is happening. // Event represents something that has happened or is happening.

View file

@ -62,7 +62,7 @@ func splitModule(arg string) (module, version string, err error) {
err = fmt.Errorf("module name is required") err = fmt.Errorf("module name is required")
} }
return return module, version, err
} }
func cmdAddPackage(fl Flags) (int, error) { func cmdAddPackage(fl Flags) (int, error) {
@ -217,7 +217,7 @@ func getModules() (standard, nonstandard, unknown []moduleInfo, err error) {
bi, ok := debug.ReadBuildInfo() bi, ok := debug.ReadBuildInfo()
if !ok { if !ok {
err = fmt.Errorf("no build info") err = fmt.Errorf("no build info")
return return standard, nonstandard, unknown, err
} }
for _, modID := range caddy.Modules() { for _, modID := range caddy.Modules() {
@ -260,7 +260,7 @@ func getModules() (standard, nonstandard, unknown []moduleInfo, err error) {
nonstandard = append(nonstandard, caddyModGoMod) nonstandard = append(nonstandard, caddyModGoMod)
} }
} }
return return standard, nonstandard, unknown, err
} }
func listModules(path string) error { func listModules(path string) error {

View file

@ -261,14 +261,14 @@ func (fcpc *fakeClosePacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err e
if atomic.LoadInt32(&fcpc.closed) == 1 { if atomic.LoadInt32(&fcpc.closed) == 1 {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() { if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
if err = fcpc.SetReadDeadline(time.Time{}); err != nil { if err = fcpc.SetReadDeadline(time.Time{}); err != nil {
return return n, addr, err
} }
} }
} }
return return n, addr, err
} }
return return n, addr, err
} }
// Close won't close the underlying socket unless there is no more reference, then listenerPool will close it. // Close won't close the underlying socket unless there is no more reference, then listenerPool will close it.

View file

@ -382,7 +382,7 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) {
a = afterSlash a = afterSlash
if IsUnixNetwork(network) || IsFdNetwork(network) { if IsUnixNetwork(network) || IsFdNetwork(network) {
host = a host = a
return return network, host, port, err
} }
} }
@ -402,7 +402,7 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) {
err = errors.Join(firstErr, err) err = errors.Join(firstErr, err)
} }
return return network, host, port, err
} }
// JoinNetworkAddress combines network, host, and port into a single // JoinNetworkAddress combines network, host, and port into a single

View file

@ -209,7 +209,7 @@ func errLogValues(err error) (status int, msg string, fields func() []zapcore.Fi
zap.String("err_trace", handlerErr.Trace), zap.String("err_trace", handlerErr.Trace),
} }
} }
return return status, msg, fields
} }
fields = func() []zapcore.Field { fields = func() []zapcore.Field {
return []zapcore.Field{ return []zapcore.Field{
@ -218,7 +218,7 @@ func errLogValues(err error) (status int, msg string, fields func() []zapcore.Fi
} }
status = http.StatusInternalServerError status = http.StatusInternalServerError
msg = err.Error() msg = err.Error()
return return status, msg, fields
} }
// ExtraLogFields is a list of extra fields to log with every request. // ExtraLogFields is a list of extra fields to log with every request.

View file

@ -116,7 +116,7 @@ func (ew errorWrapper) Read(p []byte) (n int, err error) {
if errors.As(err, &mbe) { if errors.As(err, &mbe) {
err = caddyhttp.Error(http.StatusRequestEntityTooLarge, err) err = caddyhttp.Error(http.StatusRequestEntityTooLarge, err)
} }
return return n, err
} }
// Interface guard // Interface guard

View file

@ -154,13 +154,13 @@ func (c *client) Do(p map[string]string, req io.Reader) (r io.Reader, err error)
err = writer.writeBeginRequest(uint16(Responder), 0) err = writer.writeBeginRequest(uint16(Responder), 0)
if err != nil { if err != nil {
return return r, err
} }
writer.recType = Params writer.recType = Params
err = writer.writePairs(p) err = writer.writePairs(p)
if err != nil { if err != nil {
return return r, err
} }
writer.recType = Stdin writer.recType = Stdin
@ -176,7 +176,7 @@ func (c *client) Do(p map[string]string, req io.Reader) (r io.Reader, err error)
} }
r = &streamReader{c: c} r = &streamReader{c: c}
return return r, err
} }
// clientCloser is a io.ReadCloser. It wraps a io.Reader with a Closer // clientCloser is a io.ReadCloser. It wraps a io.Reader with a Closer
@ -213,7 +213,7 @@ func (f clientCloser) Close() error {
func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Response, err error) { func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Response, err error) {
r, err := c.Do(p, req) r, err := c.Do(p, req)
if err != nil { if err != nil {
return return resp, err
} }
rb := bufio.NewReader(r) rb := bufio.NewReader(r)
@ -223,7 +223,7 @@ func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Respons
// Parse the response headers. // Parse the response headers.
mimeHeader, err := tp.ReadMIMEHeader() mimeHeader, err := tp.ReadMIMEHeader()
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
return return resp, err
} }
resp.Header = http.Header(mimeHeader) resp.Header = http.Header(mimeHeader)
@ -231,7 +231,7 @@ func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Respons
statusNumber, statusInfo, statusIsCut := strings.Cut(resp.Header.Get("Status"), " ") statusNumber, statusInfo, statusIsCut := strings.Cut(resp.Header.Get("Status"), " ")
resp.StatusCode, err = strconv.Atoi(statusNumber) resp.StatusCode, err = strconv.Atoi(statusNumber)
if err != nil { if err != nil {
return return resp, err
} }
if statusIsCut { if statusIsCut {
resp.Status = statusInfo resp.Status = statusInfo
@ -260,7 +260,7 @@ func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Respons
} }
resp.Body = closer resp.Body = closer
return return resp, err
} }
// Get issues a GET request to the fcgi responder. // 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]
for _, v0 := range val { for _, v0 := range val {
err = writer.WriteField(key, v0) err = writer.WriteField(key, v0)
if err != nil { if err != nil {
return return resp, err
} }
} }
} }
@ -347,13 +347,13 @@ func (c *client) PostFile(p map[string]string, data url.Values, file map[string]
} }
_, err = io.Copy(part, fd) _, err = io.Copy(part, fd)
if err != nil { if err != nil {
return return resp, err
} }
} }
err = writer.Close() err = writer.Close()
if err != nil { if err != nil {
return return resp, err
} }
return c.Post(p, "POST", bodyType, buf, int64(buf.Len())) return c.Post(p, "POST", bodyType, buf, int64(buf.Len()))

View file

@ -120,7 +120,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
conn, err := net.Dial("tcp", ipPort) conn, err := net.Dial("tcp", ipPort)
if err != nil { if err != nil {
log.Println("err:", err) log.Println("err:", err)
return return content
} }
fcgi := client{rwc: conn, reqID: 1} fcgi := client{rwc: conn, reqID: 1}
@ -162,7 +162,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
if err != nil { if err != nil {
log.Println("err:", err) log.Println("err:", err)
return return content
} }
defer resp.Body.Close() defer resp.Body.Close()
@ -176,7 +176,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
globalt.Error("Server return failed message") globalt.Error("Server return failed message")
} }
return return content
} }
func generateRandFile(size int) (p string, m string) { func generateRandFile(size int) (p string, m string) {
@ -206,7 +206,7 @@ func generateRandFile(size int) (p string, m string) {
} }
} }
m = fmt.Sprintf("%x", h.Sum(nil)) m = fmt.Sprintf("%x", h.Sum(nil))
return return p, m
} }
func DisabledTest(t *testing.T) { func DisabledTest(t *testing.T) {

View file

@ -30,23 +30,23 @@ func (rec *record) fill(r io.Reader) (err error) {
rec.lr.N = rec.padding rec.lr.N = rec.padding
rec.lr.R = r rec.lr.R = r
if _, err = io.Copy(io.Discard, rec); err != nil { if _, err = io.Copy(io.Discard, rec); err != nil {
return return err
} }
if err = binary.Read(r, binary.BigEndian, &rec.h); err != nil { if err = binary.Read(r, binary.BigEndian, &rec.h); err != nil {
return return err
} }
if rec.h.Version != 1 { if rec.h.Version != 1 {
err = errors.New("fcgi: invalid header version") err = errors.New("fcgi: invalid header version")
return return err
} }
if rec.h.Type == EndRequest { if rec.h.Type == EndRequest {
err = io.EOF err = io.EOF
return return err
} }
rec.lr.N = int64(rec.h.ContentLength) rec.lr.N = int64(rec.h.ContentLength)
rec.padding = int64(rec.h.PaddingLength) rec.padding = int64(rec.h.PaddingLength)
return return err
} }
func (rec *record) Read(p []byte) (n int, err error) { func (rec *record) Read(p []byte) (n int, err error) {

View file

@ -588,11 +588,11 @@ func (m *maxLatencyWriter) Write(p []byte) (n int, err error) {
m.logger.Debug("flushing immediately") m.logger.Debug("flushing immediately")
//nolint:errcheck //nolint:errcheck
m.flush() m.flush()
return return n, err
} }
if m.flushPending { if m.flushPending {
m.logger.Debug("delayed flush already pending") m.logger.Debug("delayed flush already pending")
return return n, err
} }
if m.t == nil { if m.t == nil {
m.t = time.AfterFunc(m.latency, m.delayedFlush) m.t = time.AfterFunc(m.latency, m.delayedFlush)
@ -603,7 +603,7 @@ func (m *maxLatencyWriter) Write(p []byte) (n int, err error) {
c.Write(zap.Duration("duration", m.latency)) c.Write(zap.Duration("duration", m.latency))
} }
m.flushPending = true m.flushPending = true
return return n, err
} }
func (m *maxLatencyWriter) delayedFlush() { func (m *maxLatencyWriter) delayedFlush() {

View file

@ -213,12 +213,12 @@ func (su SRVUpstreams) expandedAddr(r *http.Request) (addr, service, proto, name
name = repl.ReplaceAll(su.Name, "") name = repl.ReplaceAll(su.Name, "")
if su.Service == "" && su.Proto == "" { if su.Service == "" && su.Proto == "" {
addr = name addr = name
return return addr, service, proto, name
} }
service = repl.ReplaceAll(su.Service, "") service = repl.ReplaceAll(su.Service, "")
proto = repl.ReplaceAll(su.Proto, "") proto = repl.ReplaceAll(su.Proto, "")
addr = su.formattedAddr(service, proto, name) addr = su.formattedAddr(service, proto, name)
return return addr, service, proto, name
} }
// formattedAddr the RFC 2782 representation of the SRV domain, in // formattedAddr the RFC 2782 representation of the SRV domain, in

View file

@ -220,13 +220,13 @@ func (a *adminAPI) getCAFromAPIRequestPath(r *http.Request) (*CA, error) {
func rootAndIntermediatePEM(ca *CA) (root, inter []byte, err error) { func rootAndIntermediatePEM(ca *CA) (root, inter []byte, err error) {
root, err = pemEncodeCert(ca.RootCertificate().Raw) root, err = pemEncodeCert(ca.RootCertificate().Raw)
if err != nil { if err != nil {
return return root, inter, err
} }
inter, err = pemEncodeCert(ca.IntermediateCertificate().Raw) inter, err = pemEncodeCert(ca.IntermediateCertificate().Raw)
if err != nil { if err != nil {
return return root, inter, err
} }
return return root, inter, err
} }
// caInfo is the response structure for the CA info API endpoint. // caInfo is the response structure for the CA info API endpoint.

View file

@ -172,7 +172,7 @@ func (reconn *redialerConn) Write(b []byte) (n int, err error) {
reconn.connMu.RUnlock() reconn.connMu.RUnlock()
if conn != nil { if conn != nil {
if n, err = conn.Write(b); err == nil { if n, err = conn.Write(b); err == nil {
return return n, err
} }
} }
@ -184,7 +184,7 @@ func (reconn *redialerConn) Write(b []byte) (n int, err error) {
// one of them might have already re-dialed by now; try writing again // one of them might have already re-dialed by now; try writing again
if reconn.Conn != nil { if reconn.Conn != nil {
if n, err = reconn.Conn.Write(b); err == nil { if n, err = reconn.Conn.Write(b); err == nil {
return return n, err
} }
} }
@ -198,7 +198,7 @@ func (reconn *redialerConn) Write(b []byte) (n int, err error) {
if err2 != nil { if err2 != nil {
// logger socket still offline; instead of discarding the log, dump it to stderr // logger socket still offline; instead of discarding the log, dump it to stderr
os.Stderr.Write(b) os.Stderr.Write(b)
return return n, err
} }
if n, err = conn2.Write(b); err == nil { if n, err = conn2.Write(b); err == nil {
if reconn.Conn != nil { if reconn.Conn != nil {
@ -211,7 +211,7 @@ func (reconn *redialerConn) Write(b []byte) (n int, err error) {
os.Stderr.Write(b) os.Stderr.Write(b)
} }
return return n, err
} }
func (reconn *redialerConn) dial() (net.Conn, error) { func (reconn *redialerConn) dial() (net.Conn, error) {

View file

@ -106,7 +106,7 @@ func (up *UsagePool) LoadOrNew(key any, construct Constructor) (value any, loade
} }
upv.Unlock() upv.Unlock()
} }
return return value, loaded, err
} }
// LoadOrStore loads the value associated with key from the pool if it // 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) {
up.Unlock() up.Unlock()
value = val value = val
} }
return return value, loaded
} }
// Range iterates the pool similarly to how sync.Map.Range() does: // 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) {
upv.value, upv.refs)) upv.value, upv.refs))
} }
} }
return return deleted, err
} }
// References returns the number of references (count of usages) to a // References returns the number of references (count of usages) to a