When a package's module is not at its import path root (XS-Go-Import-Path
github.com/josephburnett/jd, module github.com/josephburnett/jd/v2 in v2/),
autopkgtest fails with
go: workspace module github.com/josephburnett/jd/v2 is replaced at all
versions in the go.work file.
_create_go_work_file writes "use ./src/.../jd/v2" for the child module, then
skips replaces only for @targets (line 1038), which holds the import path
root. Under autopkgtest the installed copy of the package itself is in
auto_module_mappings, so go.work also gets "replace .../jd/v2 => ...". A
plain build never has the package installed, so it does not show there.
@use_modules, filled a few lines above (961-973), already holds every module
that got a use line, including the root case. The fix is to check it instead:
- next if grep { $_ eq $module } @targets;
+ next if grep { $_ eq $module } @use_modules;
Workaround meanwhile: DH_GOLANG_BUILDPKG := github.com/josephburnett/jd/v2/...
puts the module in @targets. With it autopkgtest passes and the .deb is byte
identical, so only the workspace changes.
https://salsa.debian.org/go-team/dh-go/-/merge_requests/9 (open) rebuilds
@use_modules in the same function but does not touch this check; with it the
list can hold a parent module, so comparing against @targets stays wrong.
Related go.work bugs: https://bugs.debian.org/1149023 and
https://bugs.debian.org/1151332 .
The diff above is the whole fix; I can also open it as a merge request on
https://salsa.debian.org/go-team/dh-go .