refactor: apply go fix modernizers for Go 1.26
Automated fixes: interface{} → any, range-over-int, t.Context(),
wg.Go(), strings.SplitSeq, strings.Builder, slices.Contains,
maps helpers, min/max builtins.
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
6d07388407
commit
dff5fb23c5
9 changed files with 34 additions and 40 deletions
|
|
@ -35,7 +35,7 @@ func setupBenchMetricsDir(b *testing.B) string {
|
|||
func seedEvents(b *testing.B, n int) {
|
||||
b.Helper()
|
||||
now := time.Now()
|
||||
for i := 0; i < n; i++ {
|
||||
for i := range n {
|
||||
ev := Event{
|
||||
Type: fmt.Sprintf("type-%d", i%10),
|
||||
Timestamp: now.Add(-time.Duration(i) * time.Millisecond),
|
||||
|
|
@ -162,7 +162,7 @@ func BenchmarkMetricsRecordAndQuery(b *testing.B) {
|
|||
now := time.Now()
|
||||
|
||||
// Write 10K events
|
||||
for i := 0; i < 10_000; i++ {
|
||||
for i := range 10_000 {
|
||||
ev := Event{
|
||||
Type: fmt.Sprintf("type-%d", i%10),
|
||||
Timestamp: now,
|
||||
|
|
@ -206,7 +206,7 @@ func TestMetricsRecordAndRead_10K_Good(t *testing.T) {
|
|||
const n = 10_000
|
||||
|
||||
// Write events
|
||||
for i := 0; i < n; i++ {
|
||||
for i := range n {
|
||||
ev := Event{
|
||||
Type: fmt.Sprintf("type-%d", i%10),
|
||||
Timestamp: now.Add(-time.Duration(i) * time.Millisecond),
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -143,4 +143,4 @@ require (
|
|||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
)
|
||||
|
|
|
|||
22
go.sum
22
go.sum
|
|
@ -1,11 +1,17 @@
|
|||
forge.lthn.ai/core/go v0.0.0-20260221191103-d091fa62023f h1:CcSh/FFY93K5m0vADHLxwxKn2pTIM8HzYX1eGa4WZf4=
|
||||
forge.lthn.ai/core/go v0.0.0-20260221191103-d091fa62023f/go.mod h1:WCPJVEZm/6mTcJimHV0uX8ZhnKEF3dN0rQp13ByaSPg=
|
||||
forge.lthn.ai/core/go-api v0.0.0-20260221015744-0d3479839dc5 h1:60reee4fmT4USZqEd6dyCTXsTj47eOOEc6Pp0HHJbd0=
|
||||
forge.lthn.ai/core/go-api v0.0.0-20260221015744-0d3479839dc5/go.mod h1:f0hPLX+GZT/ME8Tb7c8wVDlfLqnpOKRwf2k5lpJq87g=
|
||||
forge.lthn.ai/core/go-crypt v0.0.0-20260221190941-9585da8e6649 h1:Rs3bfSU8u1wkzYeL21asL7IcJIBVwOhtRidcEVj/PkA=
|
||||
forge.lthn.ai/core/go-crypt v0.0.0-20260221190941-9585da8e6649/go.mod h1:RS+sz5lChrbc1AEmzzOULsTiMv3bwcwVtwbZi+c/Yjk=
|
||||
forge.lthn.ai/core/go-rag v0.0.0-20260221193811-2a8d8b0820b5 h1:AD7a3IY0W/LaxmPRnPkxuxbWYw11/jsm2zELG1FfSNY=
|
||||
forge.lthn.ai/core/go-rag v0.0.0-20260221193811-2a8d8b0820b5/go.mod h1:s5OWHz87LELq2UKk93cBFJA9pydLoytHN1pPbgX0ShE=
|
||||
forge.lthn.ai/core/go v0.0.1 h1:6DFABiGUccu3iQz2avpYbh0X24xccIsve6TSipziKT4=
|
||||
forge.lthn.ai/core/go v0.0.1/go.mod h1:vr4W9GMcyKbOJWmo22zQ9KmzLbdr2s17Q6LkVjpOeFU=
|
||||
forge.lthn.ai/core/go-api v0.0.1 h1:skuZYxkei+kLfVoOJs3524zlkk4REVWb9tdHnugCqlk=
|
||||
forge.lthn.ai/core/go-api v0.0.1/go.mod h1:sWp6xNaWXk+5SJD7YannnKvdqgT6oMx8cUgCq7I2p38=
|
||||
forge.lthn.ai/core/go-crypt v0.0.1 h1:dq+TqMGEOonKZTfBolCVLqakYnKrdhav/zTKpiNhvOs=
|
||||
forge.lthn.ai/core/go-crypt v0.0.1/go.mod h1:s3UvyM48vq4kZcdM2WDxFAU+KTcZK6N+WuNHG3FOyJ8=
|
||||
forge.lthn.ai/core/go-inference v0.0.1 h1:87kCwOS0wWAE38zyKz/UDWjv2rfI9gQaYXvrUBPzcEY=
|
||||
forge.lthn.ai/core/go-inference v0.0.1/go.mod h1:hmLtynfw1yo0ByuX3pslLZMgCdqJH2r+2+wGJDhmmi0=
|
||||
forge.lthn.ai/core/go-ml v0.0.1 h1:0FjLafT4nHzDqdS5DLga3yV7q0SI/L0UQLdbaw5MVQo=
|
||||
forge.lthn.ai/core/go-ml v0.0.1/go.mod h1:E8KeNoiAmALlpjZHsIIg4tw3AROPpSsX1+MwbIFQX54=
|
||||
forge.lthn.ai/core/go-mlx v0.0.1 h1:xTi0X+noGYNmRcRuwLV4KwtIOT5QOxmGKzsTIchw80g=
|
||||
forge.lthn.ai/core/go-mlx v0.0.1/go.mod h1:r+72UbUMXnVjRzml29lHxRvFThdQl/LwEEsyYMsRrOY=
|
||||
forge.lthn.ai/core/go-rag v0.0.1 h1:a6+qgk8QRFZYz6hnkC1VXk/XbIM0k15Ut37g74t79hc=
|
||||
forge.lthn.ai/core/go-rag v0.0.1/go.mod h1:h5fMwN7MEKOaZgTs35bEKTzpCIw1q5G/lZoVpiZduDo=
|
||||
github.com/99designs/gqlgen v0.17.87 h1:pSnCIMhBQezAE8bc1GNmfdLXFmnWtWl1GRDFEE/nHP8=
|
||||
github.com/99designs/gqlgen v0.17.87/go.mod h1:fK05f1RqSNfQpd4CfW5qk/810Tqi4/56Wf6Nem0khAg=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
|
||||
|
|
|
|||
|
|
@ -62,8 +62,7 @@ func TestBridge_Good_ConnectAndSend(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
hub := ws.NewHub()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
go hub.Run(ctx)
|
||||
|
||||
cfg := DefaultConfig()
|
||||
|
|
@ -89,8 +88,7 @@ func TestBridge_Good_Shutdown(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
hub := ws.NewHub()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
go hub.Run(ctx)
|
||||
|
||||
cfg := DefaultConfig()
|
||||
|
|
@ -147,8 +145,7 @@ func TestBridge_Good_MessageDispatch(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
hub := ws.NewHub()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
go hub.Run(ctx)
|
||||
|
||||
cfg := DefaultConfig()
|
||||
|
|
@ -194,8 +191,7 @@ func TestBridge_Good_Reconnect(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
hub := ws.NewHub()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
go hub.Run(ctx)
|
||||
|
||||
cfg := DefaultConfig()
|
||||
|
|
@ -233,8 +229,7 @@ func TestBridge_Good_ExponentialBackoff(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
hub := ws.NewHub()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
go hub.Run(ctx)
|
||||
|
||||
cfg := DefaultConfig()
|
||||
|
|
@ -302,8 +297,7 @@ func TestBridge_Good_ReconnectDetectsServerShutdown(t *testing.T) {
|
|||
}))
|
||||
|
||||
hub := ws.NewHub()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
go hub.Run(ctx)
|
||||
|
||||
cfg := DefaultConfig()
|
||||
|
|
@ -354,8 +348,7 @@ func TestBridge_Good_AuthHeader(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
hub := ws.NewHub()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
go hub.Run(ctx)
|
||||
|
||||
cfg := DefaultConfig()
|
||||
|
|
@ -400,8 +393,7 @@ func TestBridge_Good_NoAuthHeaderWhenTokenEmpty(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
hub := ws.NewHub()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
go hub.Run(ctx)
|
||||
|
||||
cfg := DefaultConfig()
|
||||
|
|
|
|||
|
|
@ -758,8 +758,7 @@ func TestChatSend_Good_BridgeMessageType(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
hub := ws.NewHub()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
go hub.Run(ctx)
|
||||
|
||||
sub := New(hub, WithLaravelURL(wsURL(ts)), WithReconnectInterval(50*time.Millisecond))
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func structSchema(v any) map[string]any {
|
|||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
if t.Kind() == reflect.Ptr {
|
||||
if t.Kind() == reflect.Pointer {
|
||||
t = t.Elem()
|
||||
}
|
||||
if t.Kind() != reflect.Struct {
|
||||
|
|
@ -74,8 +74,8 @@ func structSchema(v any) map[string]any {
|
|||
properties := make(map[string]any)
|
||||
required := make([]string, 0)
|
||||
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
f := t.Field(i)
|
||||
for f := range t.Fields() {
|
||||
f := f
|
||||
if !f.IsExported() {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,10 +141,7 @@ func (s *Service) metricsQuery(ctx context.Context, req *mcp.CallToolRequest, in
|
|||
}
|
||||
|
||||
// Get recent events (last 10, most recent first)
|
||||
startIdx := len(events) - DefaultMetricsLimit
|
||||
if startIdx < 0 {
|
||||
startIdx = 0
|
||||
}
|
||||
startIdx := max(len(events)-DefaultMetricsLimit, 0)
|
||||
for i := len(events) - 1; i >= startIdx; i-- {
|
||||
ev := events[i]
|
||||
output.Events = append(output.Events, MetricEventBrief{
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ func (m *MLSubsystem) mlScore(ctx context.Context, req *mcp.CallToolRequest, inp
|
|||
|
||||
output := MLScoreOutput{}
|
||||
|
||||
for _, suite := range strings.Split(suites, ",") {
|
||||
for suite := range strings.SplitSeq(suites, ",") {
|
||||
suite = strings.TrimSpace(suite)
|
||||
switch suite {
|
||||
case "heuristic":
|
||||
|
|
@ -208,7 +208,7 @@ func (m *MLSubsystem) mlProbe(ctx context.Context, req *mcp.CallToolRequest, inp
|
|||
probes := ml.CapabilityProbes
|
||||
if input.Categories != "" {
|
||||
cats := make(map[string]bool)
|
||||
for _, c := range strings.Split(input.Categories, ",") {
|
||||
for c := range strings.SplitSeq(input.Categories, ",") {
|
||||
cats[strings.TrimSpace(c)] = true
|
||||
}
|
||||
var filtered []ml.Probe
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ func TestServeTCP_MultipleConnections(t *testing.T) {
|
|||
|
||||
// Connect multiple clients
|
||||
const numClients = 3
|
||||
for i := 0; i < numClients; i++ {
|
||||
for i := range numClients {
|
||||
conn, err := net.Dial("tcp", actualAddr)
|
||||
if err != nil {
|
||||
t.Fatalf("Client %d failed to connect: %v", i, err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue