upgrade golangci to v2

* migrate configuration to version 2
* fix new lint warnings
* update lint.yaml to use golangci-lint-action v7
This commit is contained in:
Lawrence, Rendall
2025-04-22 14:18:18 +03:00
parent 750a76b756
commit 1a3f5b1598
7 changed files with 63 additions and 60 deletions
+4 -4
View File
@@ -117,7 +117,7 @@ func (cfg Config) Validate() (validCfg Config, err error) {
Strs("default", validCfg.ScrapeRoutes).
Msg("falling back to default configuration")
}
validCfg.ParseOptions.ParseOptions = cfg.ParseOptions.ParseOptions.Validate(logger)
validCfg.ParseOptions.ParseOptions = cfg.ParseOptions.Validate(logger)
return
}
@@ -163,7 +163,7 @@ func NewFrontend(c conf.MapConfig, logic *middleware.Logic) (frontend.Frontend,
return nil, err
}
certs := []tls.Certificate{cert}
f.Server.TLSConfig = &tls.Config{
f.TLSConfig = &tls.Config{
Certificates: certs,
MinVersion: tls.VersionTLS12,
}
@@ -194,7 +194,7 @@ func NewFrontend(c conf.MapConfig, logic *middleware.Logic) (frontend.Frontend,
pathRouting[path.Clean(route)] = f.ping
}
f.Server.Handler = func(ctx *fasthttp.RequestCtx) {
f.Handler = func(ctx *fasthttp.RequestCtx) {
if route, exists := pathRouting[string(ctx.Path())]; exists {
route(ctx)
} else {
@@ -228,7 +228,7 @@ func runServer(s *fasthttp.Server, cfg *Config) {
func (f *httpFE) Close() (err error) {
f.onceCloser.Do(func() {
if f.Server != nil {
err = f.Server.Shutdown()
err = f.Shutdown()
}
})
+3 -2
View File
@@ -2,9 +2,10 @@ package http
import (
"github.com/rs/zerolog"
"github.com/valyala/fasthttp"
"github.com/sot-tech/mochi/bittorrent"
"github.com/sot-tech/mochi/pkg/str2bytes"
"github.com/valyala/fasthttp"
)
// queryParams parses a URL Query and implements the Params interface with some
@@ -33,5 +34,5 @@ func (qp queryParams) InfoHashes() bittorrent.InfoHashes {
// MarshalZerologObject writes fields into zerolog event
func (qp queryParams) MarshalZerologObject(e *zerolog.Event) {
e.Str("query", str2bytes.BytesToString(qp.Args.QueryString()))
e.Str("query", str2bytes.BytesToString(qp.QueryString()))
}