testcontainers / testcontainers-go

Testcontainers for Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.
https://golang.testcontainers.org
MIT License
3.67k stars 504 forks source link

feat: support for go.work #2849

Open mdelapenya opened 4 weeks ago

mdelapenya commented 4 weeks ago

What does this PR do?

This PR adds support for creating a go.work file and managing it when new modules are created using the modulegen tool.

During this process, we had to rework a bit this code generation tool, using the modfile package to handle the workfile programatically. Besides that, we updated the existing tests to check the work files are properly generated, also moving tests to the right package and even removing duplicated tests (e.g. for validation).

Finally, we are improving the error messages, following recent patterns we are adopting in the library.

Important to notice the amount of lines in the changeset comes from running go work sync, which updated all the dependencies.

Why is it important?

Now the go toolchain will be able to handle the core module and its submodules in a proper manner, so it would be much easier to setup the IDE when working on the project. In the past, we generated code for VSCode and handle all the submodules, now it would be possible to just open the root dir, and because of the existence of the go.work file, the IDE would be able to follow all links across the entire code base.

Related issues

netlify[bot] commented 4 weeks ago

Deploy Preview for testcontainers-go ready!

Name Link
Latest commit cbfdea7c474c6b563b8094ddb827abff01885f3c
Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/6720b6999366710008b34bb6
Deploy Preview https://deploy-preview-2849--testcontainers-go.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

mdelapenya commented 3 weeks ago

@mmorel-35 pinging you for a review (if possible), as you worked in the modulegen a lot 🙏