go-arch-lint icon indicating copy to clipboard operation
go-arch-lint copied to clipboard

Avoid/optimize packages.Load

Open fe3dback opened this issue 3 years ago • 4 comments

For parsing AST, we use lib called "packages", is go stdlib from x Currently this lib requre all go installation in host, so it platform dependant thing. And most horrible, we need to include all GO setup inside docker release images.

In this ticket, we need at least remove all not needed files from go18-buster image and reduce linter size and at most, replace packages.Load for something else.

read more:

  • https://github.com/golang/mock/pull/420
  • https://github.com/vektra/mockery/issues/258

fe3dback avatar Jun 23 '22 19:06 fe3dback

Because of this x package requirement, release image increased:

  • dev-v1.7.2-rc1 (320.61 MB)
  • release-v1.7.1 (5.24 MB)

fe3dback avatar Jun 23 '22 19:06 fe3dback

Also build/stdextractor not needed anymore, because packages.Load used anyway for parsing AST.

previosly we use it to bake std imports inside binary, without parsing it in runtime

fe3dback avatar Jun 23 '22 19:06 fe3dback

I haven't really dug deep into go-arch-lint's source code, but it seems to me, that linting dependencies could be done solely by parsing import statements in a package, which in itself is a rather trivial thing to do. Perhaps, we could replace packages with custom written parser specifically for import sections?

SealOfTime avatar Feb 22 '24 17:02 SealOfTime

For linting imports, we don't have to use 'packages' at all, that's how it been before in old versions. But linter with the deepScan flag enabled, reads all GO code, not just imports. This required to check for dependency injection, function calls, etc.

fe3dback avatar Feb 22 '24 19:02 fe3dback