From c0161bd3cc7e592f6128510f82ce636790fd7834 Mon Sep 17 00:00:00 2001 From: forgoty Date: Fri, 5 Dec 2025 19:28:52 +0100 Subject: [PATCH] issue(external module): add external module test case --- cleanarch/cleanarch_test.go | 1 + examples/external-module/README.md | 3 +++ examples/external-module/moduleA/go.mod | 5 +++++ .../moduleA/internal/application/service.go | 9 +++++++++ examples/external-module/moduleB/application/errors.go | 5 +++++ examples/external-module/moduleB/go.mod | 3 +++ 6 files changed, 26 insertions(+) create mode 100644 examples/external-module/README.md create mode 100644 examples/external-module/moduleA/go.mod create mode 100644 examples/external-module/moduleA/internal/application/service.go create mode 100644 examples/external-module/moduleB/application/errors.go create mode 100644 examples/external-module/moduleB/go.mod diff --git a/cleanarch/cleanarch_test.go b/cleanarch/cleanarch_test.go index 37171bd..673fe62 100644 --- a/cleanarch/cleanarch_test.go +++ b/cleanarch/cleanarch_test.go @@ -60,6 +60,7 @@ func TestValidator_Validate(t *testing.T) { IsValid: true, IgnoredPackages: []string{"github.com/roblaszczak/go-cleanarch/examples/ignore-package/app"}, }, + {Path: "../examples/external-module/moduleA", IsValid: true}, } for _, c := range testCases { diff --git a/examples/external-module/README.md b/examples/external-module/README.md new file mode 100644 index 0000000..757c6dc --- /dev/null +++ b/examples/external-module/README.md @@ -0,0 +1,3 @@ +# External module imports + +moduleA imports from external Go module moduleB with same layer name. diff --git a/examples/external-module/moduleA/go.mod b/examples/external-module/moduleA/go.mod new file mode 100644 index 0000000..dc72de2 --- /dev/null +++ b/examples/external-module/moduleA/go.mod @@ -0,0 +1,5 @@ +module github.com/external/moduleA + +go 1.21 + +replace github.com/external/moduleB => ../moduleB diff --git a/examples/external-module/moduleA/internal/application/service.go b/examples/external-module/moduleA/internal/application/service.go new file mode 100644 index 0000000..836545c --- /dev/null +++ b/examples/external-module/moduleA/internal/application/service.go @@ -0,0 +1,9 @@ +package application + +import ( + "github.com/external/moduleB/application" +) + +func Handle() error { + return application.ErrNotFound +} diff --git a/examples/external-module/moduleB/application/errors.go b/examples/external-module/moduleB/application/errors.go new file mode 100644 index 0000000..32eeb19 --- /dev/null +++ b/examples/external-module/moduleB/application/errors.go @@ -0,0 +1,5 @@ +package application + +import "errors" + +var ErrNotFound = errors.New("not found") diff --git a/examples/external-module/moduleB/go.mod b/examples/external-module/moduleB/go.mod new file mode 100644 index 0000000..48711a2 --- /dev/null +++ b/examples/external-module/moduleB/go.mod @@ -0,0 +1,3 @@ +module github.com/external/moduleB + +go 1.21