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