go: only use Go build package if not using the snap
Metadata
Current evaluation
Abandoned without merging. The author withdrew the Go plugin changes after offline discussions determined the implementation required further design review before proceeding.
Suggested action: —
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh unit`?
-----
This PR makes the Go plugin prefer a Go build snap over Go installed from the archive. A staged Go has preference over both like before. Build packages will still be installed as package installation happens after the plugin initialization, so the right command will be picked afterwards.
A debug message will inform which Go was picked up.
Fixes: [LP: #1616985](https://bugs.launchpad.net/snapcraft/+bug/1616985)
The following new test is being added:
- tests.unit.plugins.go.test_go.GoPluginCommandTest
- To verify that a snap/ build package/ stage go is used respectively, by mocking the existence of the respective files, and that the debug message points at the right path. Also a test to verify that stage packages are preferred.
- Existing tests get mocked to not look for the actual Go that happens to be installed during the test run.
I locally ran the tests:
- `./runtests.sh tests/unit` with unrelated failures in [tests.unit.test_lifecycle.CoreSetupTestCase.test_core_setup_if_docker_env](https://bugs.launchpad.net/snapcraft/+bug/1752576), `tests.unit.test_mangling.TestClearExecstack.test_execstack_clears` and `tests.unit.test_elf`.
- `./runtests.sh tests/integration` with one unrelated failure in [tests.integration.general.test_parser.TestParserWikis](https://bugs.launchpad.net/snapcraft/+bug/1752580)
- `./runtests.sh static`: Everything passed
Manual test steps:
- cd tests/integration/snaps/go-hello
- Update `snapcraft.yaml` by adding this snippet to "go-hello":
build-snaps:
- go
- snapcraft -d
- Observe that the build proceeds and a message is logged saying that `/snap/bin/go` is used.
- Undo the YAML changes by removing build-snaps and `sudo snap remove go`.
- snapcraft -d
- Observe that the build succeeds and a message is logged saying "go" is used.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Abandoned without merging. The author withdrew the Go plugin changes after offline discussions determined the implementation required further design review before proceeding. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed and abandoned by the author. Offline discussions determined the Go plugin priority changes require further design review before implementation. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without merging. The author abandoned the pull request after determining it requires further design discussion. No code changes were integrated. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1616985 the go plugin doesn't use go build-snaps | snapcraft (launchpad) | closed | Resolved by adding build-snap support to snapcraft and publishing a dedicated go snap. The go plugin was updated to use the go build-snap instead of the legacy deb package, enabling support for newer Go versions. | |
| #2194 plugins: do not install go debs if go snap is used | snapcraft | merged | Merged a fix to the go plugin that skips installing the golang-go deb package when a go build-snap is defined, resolving PATH conflicts. Approved by reviewers, passed CI with full coverage, and integrated into master. | |
| #1751 the go plugin doesn't use go build-snaps | snapcraft | closed | Closed without resolution or discussion. The report appears abandoned or superseded, with no fix implemented or merge details provided. |