Hi Sebastian,
On 9/11/21 10:06 PM, Sebastian wrote:
I would be very interested to see how this might work; presumably, for
when the Go build tool attempts to download the dependencies, a proxy
server would need to be used in the CI/CD to translate the package paths
into ones pointing to the Debian packages.
You can look at this file to understand better how the golang build
system works in Debian:
/usr/share/perl5/Debian/Debhelper/Buildsystem/golang.pm
You can get a glimpse of the GO env variables that are set:
grep 'ENV{GO.*} ='
/usr/share/perl5/Debian/Debhelper/Buildsystem/golang.pm
$ENV{GOPATH} = $this->{cwd} . '/' . $this->get_builddir();
$ENV{GOCACHE} = $this->{cwd} . '/' . $this->get_buildpath('go-build')
$ENV{GO111MODULE} = "off";
$ENV{GOPROXY} = "off";
$ENV{GOOS} = $goos;
GOPROXY is set to off to disable any download, see [1]. So the
dependencies have to be installed in advanced in the build environment.
This is achieved by listing the Build-Dependencies in the debian/control
file.
All the golang dev packages are installed in usr/share/gocode if I'm not
mistaken. Then dh_golang does some magic to make it available in the
build directory. This is explained by "man dh-golang":
configure
Creates a Go workspace (see
https://golang.org/doc/code.html#Workspaces) in the build directory.
Copies the source code into that workspace and symlinks all available
libraries from
/usr/share/gocode/src into the workspace because the go(1)
tool requires write access to the workspace. See also
"DH_GOLANG_INSTALL_EXTRA" and "DH_GOLANG_INSTALL_ALL".
Hope this helps!
Arnaud
----
[1]: https://golang.org/ref/mod#environment-variables