From 4c17be4e465585c4aa9b99fd306a464e5d36e61b Mon Sep 17 00:00:00 2001 From: Snider Date: Mon, 9 Mar 2026 13:58:18 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20resolve=20variable=20shadowing=20in=20te?= =?UTF-8?q?st=20files=20(core=20=E2=86=92=20framework=20alias)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Local variable `core` shadowed the package import `core`, causing `core.ServiceFor` to be interpreted as a method call instead of a package-level function. Aliased import as `framework`. Also fixes pre-existing compilation failure in go-process test suite. Co-Authored-By: Claude Opus 4.6 --- global_test.go | 26 +++++++++++++------------- runner_test.go | 8 ++++---- service_test.go | 20 ++++++++++---------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/global_test.go b/global_test.go index 3b0a2af..5aa99e0 100644 --- a/global_test.go +++ b/global_test.go @@ -5,7 +5,7 @@ import ( "sync" "testing" - "forge.lthn.ai/core/go/pkg/core" + framework "forge.lthn.ai/core/go/pkg/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -53,12 +53,12 @@ func TestGlobal_SetDefault(t *testing.T) { } }() - core, err := core.New( - core.WithName("process", NewService(Options{})), + c, err := framework.New( + framework.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := core.ServiceFor[*Service](core, "process") + svc, err := framework.ServiceFor[*Service](c, "process") require.NoError(t, err) SetDefault(svc) @@ -81,12 +81,12 @@ func TestGlobal_ConcurrentDefault(t *testing.T) { } }() - core, err := core.New( - core.WithName("process", NewService(Options{})), + c, err := framework.New( + framework.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := core.ServiceFor[*Service](core, "process") + svc, err := framework.ServiceFor[*Service](c, "process") require.NoError(t, err) SetDefault(svc) @@ -117,12 +117,12 @@ func TestGlobal_ConcurrentSetDefault(t *testing.T) { // Create multiple services var services []*Service for i := 0; i < 10; i++ { - core, err := core.New( - core.WithName("process", NewService(Options{})), + c, err := framework.New( + framework.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := core.ServiceFor[*Service](core, "process") + svc, err := framework.ServiceFor[*Service](c, "process") require.NoError(t, err) services = append(services, svc) } @@ -161,12 +161,12 @@ func TestGlobal_ConcurrentOperations(t *testing.T) { } }() - core, err := core.New( - core.WithName("process", NewService(Options{})), + c, err := framework.New( + framework.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := core.ServiceFor[*Service](core, "process") + svc, err := framework.ServiceFor[*Service](c, "process") require.NoError(t, err) SetDefault(svc) diff --git a/runner_test.go b/runner_test.go index 7c3f354..b1be48d 100644 --- a/runner_test.go +++ b/runner_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "forge.lthn.ai/core/go/pkg/core" + framework "forge.lthn.ai/core/go/pkg/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -12,12 +12,12 @@ import ( func newTestRunner(t *testing.T) *Runner { t.Helper() - core, err := core.New( - core.WithName("process", NewService(Options{})), + c, err := framework.New( + framework.WithName("process", NewService(Options{})), ) require.NoError(t, err) - svc, err := core.ServiceFor[*Service](core, "process") + svc, err := framework.ServiceFor[*Service](c, "process") require.NoError(t, err) return NewRunner(svc) diff --git a/service_test.go b/service_test.go index b5ad3a1..dc8c85b 100644 --- a/service_test.go +++ b/service_test.go @@ -7,23 +7,23 @@ import ( "testing" "time" - "forge.lthn.ai/core/go/pkg/core" + framework "forge.lthn.ai/core/go/pkg/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func newTestService(t *testing.T) (*Service, *core.Core) { +func newTestService(t *testing.T) (*Service, *framework.Core) { t.Helper() - core, err := core.New( - core.WithName("process", NewService(Options{BufferSize: 1024})), + c, err := framework.New( + framework.WithName("process", NewService(Options{BufferSize: 1024})), ) require.NoError(t, err) - svc, err := core.ServiceFor[*Service](core, "process") + svc, err := framework.ServiceFor[*Service](c, "process") require.NoError(t, err) - return svc, core + return svc, c } func TestService_Start(t *testing.T) { @@ -120,8 +120,8 @@ func TestService_Run(t *testing.T) { func TestService_Actions(t *testing.T) { t.Run("broadcasts events", func(t *testing.T) { - core, err := core.New( - core.WithName("process", NewService(Options{})), + c, err := framework.New( + framework.WithName("process", NewService(Options{})), ) require.NoError(t, err) @@ -130,7 +130,7 @@ func TestService_Actions(t *testing.T) { var exited []ActionProcessExited var mu sync.Mutex - core.RegisterAction(func(c *core.Core, msg core.Message) error { + c.RegisterAction(func(cc *framework.Core, msg framework.Message) error { mu.Lock() defer mu.Unlock() switch m := msg.(type) { @@ -144,7 +144,7 @@ func TestService_Actions(t *testing.T) { return nil }) - svc, _ := core.ServiceFor[*Service](core, "process") + svc, _ := framework.ServiceFor[*Service](c, "process") proc, err := svc.Start(context.Background(), "echo", "test") require.NoError(t, err)