feat: go-use checks if go.mod exists; throws error if not
Metadata
Current evaluation
Merged as commit e5af6aab: go-use plugin now raises PartsError when no go.mod exists in the part source/subdir before running go work use; test added and changelog noted.
Resolution: closed resolved
Reason: PR #1478 was merged into main as commit e5af6aab ('feat(go-use): error early if go.mod is missing'), adding the go.mod existence check in craft_parts/plugins/go_use_plugin.py:get_build_commands plus a unit test (tests/unit/plugins/test_go_use_plugin.py) and a changelog entry.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [x] Have you followed the guidelines for contributing?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] Have you successfully run `make lint && make test`?
- [x] Have you added an entry to the changelog (`docs/reference/changelog.rst`)?
---
This is from discussion #1466
Go workspace requires a go.mod to exist in the directory that's given when we call `go work init . $DIR ...` and `go work use $DIR`. The problem is that if you use the `go-use` plugin and your `source` and/or `source-subdir` points to a directory that does not contain a go.mod file, `go work use $DIR` gets called. However, the directory doesn't get added into the `go.work` file.
This PR currently throws a CraftError to the user & fails the build.
- NOTE: Do we want it to fail or have it as a warning & let the build continue? It will fail eventually b/c the module you think you added into the workspace actually didn't get added.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged as commit e5af6aab: go-use plugin now raises PartsError when no go.mod exists in the part source/subdir before running go work use; test added and changelog noted. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged in canonical/craft-parts#1478 (commit e5af6aab): go-use now checks for go.mod and raises a CraftError when it is missing. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged in canonical/craft-parts#1478 (commit e5af6aab): go-use now checks for go.mod before invoking Go workspace commands and raises an error if it is missing. | |
| qwen/qwen3.6-35b-a3b | — | — | The go-use plugin now checks for go.mod existence before running go work use. Missing files trigger a CraftError and halt the build. Merged after reviewer approval. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a go-use plugin fix that validates go.mod existence before workspace initialization. The change throws a CraftError and halts the build if missing, preventing silent configuration failures. |
Update history
No update history recorded yet.
Related work
-
Related To:
canonical/craft-parts#1466
(confidence 85%)
Sibling PR from the same discussion (#1466) adding relative-replace stripping to the go-use plugin; it referenced this go.mod check as already merged separately and remains open.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1061 check if sources can use `go-use` plugin | craft-parts | closed | Resolved in canonical/craft-parts#1478 (commit e5af6aab): go-use now checks for go.mod before running and raises PartsError when it is missing. | |
| #1466 feat: Comment out replace statements to relative paths in go.mod | craft-parts | open | Adds awk-based stripping of relative replace directives in go.mod to the go-use plugin, plus an integration test. Its go.mod existence check was already merged separately; maintainer says *-use plugins are obsolete post-Madrid. |