#1074004 dh-golang: Include //go:embed referenced files during install

#1074004#5
Date:
2024-06-21 15:19:35 UTC
From:
To:
Dear Maintainer,

Can we consider to install files referenced by //go:embed automatically or by a env
(e.g. DH_GOLANG_INSTALL_EMBED) to the build directory? This reduces manual corrections
with DH_GOLANG_INSTALL_[EXTRA/ALL] and is probably more future-proof.

Example: golang-google-protobuf
https://salsa.debian.org/go-team/packages/golang-google-protobuf/-/commit/4e6acb3b273c64905dfdf67cc3977629ad8fdd6e
Author had to initially add and now change the path since the package has moved. This
could be automated if the embedded file list can be parsed/accessed in some way:
https://salsa.debian.org/go-team/packages/golang-google-protobuf/-/blob/cf9838f774366ec018ecdf0bc975d08c30d1c879/internal/editiondefaults/defaults.go#L11

#1074004#10
Date:
2024-06-21 16:08:59 UTC
From:
To:
`go list` seem to help to find embedded files:
https://pkg.go.dev/embed#hdr-Tools
 > To support tools that analyze Go packages, the patterns found in
//go:embed lines are available in “go list” output.
 > See the EmbedPatterns, TestEmbedPatterns, and XTestEmbedPatterns
fields in the “go help list” output.

```
~/golang-google-protobuf# go list -f '{{- if .EmbedFiles -}}{{
.ImportPath }} {{ .EmbedFiles }}{{ end }}' all
crypto/internal/nistec [p256_asm_table.bin]
google.golang.org/protobuf/internal/editiondefaults
[editions_defaults.binpb]
```

#1074004#15
Date:
2024-06-21 16:13:30 UTC
From:
To:
`go list` seem to help to find embedded files:
https://pkg.go.dev/embed#hdr-Tools
 > To support tools that analyze Go packages, the patterns found in
//go:embed lines are available in “go list” output.
 > See the EmbedPatterns, TestEmbedPatterns, and XTestEmbedPatterns
fields in the “go help list” output.

```
~/golang-google-protobuf# go list -f '{{- if .EmbedFiles -}}{{
.ImportPath }} {{ .EmbedFiles }}{{ end }}' all
crypto/internal/nistec [p256_asm_table.bin]
google.golang.org/protobuf/internal/editiondefaults
[editions_defaults.binpb]
```
filter to only list files from the current source needed