#1001266 dh-golang: DH_GOLANG_EXCLUDES handling can be improved

#1001266#5
Date:
2021-12-07 10:21:46 UTC
From:
To:
Hello team,

While working on syncthing, I've noticed something weird with
the way DH_GOLANG_EXCLUDES is interpreted.

The following exclusion in d/rules:

```
export DH_GOLANG_EXCLUDES := meta
```

Will cause the exclusion of the following files from
the build targets:

```
./meta/copyright_test.go
./meta/gofmt_test.go
./meta/metalint_test.go
./lib/db/meta_test.go
./lib/db/meta.go
```

In my scenario, I only wanted to exclude files from the meta folder
(i.e meta/*) so I've updated d/rules like this:

```
export DH_GOLANG_EXCLUDES := meta/
```

And now, nothing is being filtered, previous files are now included
in the build target.

Trying to escape the exclusion: `meta\/` hasn't worked either way:
previous files are still included in the build target.

@foka (in CC) helped me fixing my syntax by using `meta($$|/)` as
an exclusion, in order to match both meta/ and meta$.
---

@foka has done a little analysis of the situation, and while
this behavior is weird, it is definitely expected:

dh-golang is doing a `go list $xs-go-import-path` against the package
and in our situation, the meta directory would appear as
github.com/syncthing/syncthing/meta (no trailing '/') and therefore
this explain why it hasn't match against the DH_GOLANG_EXCLUDES regex.

Maybe dh-golang can be improved to handle such case? (i.e trying to
match both meta/ and meta$ in this scenario).
--- @foka: the documentation about DH_GOLANG_EXCLUDES [1], is therefore currently false, since examples/ will not be excluded from build and test but from the .deb. Cheers, [1]: https://manpages.debian.org/testing/dh-golang/Debian::Debhelper::Buildsystem::golang.3pm.en.html#DH_GOLANG_EXCLUDES