Package: dh-golang
Severity: important
Tags: patch

Dear Maintainer,

dh-golang failed to build with gccgo-8.

   dh_golang -O--buildsystem=golang
        "go list -f '{{ range .Deps }}{{.}}\
{{ end }}'" github.com/elves/elvish [...]
        "go list -f '\\\
{{ .Dir }}/{{ index (or .GoFiles .CgoFiles .TestGoFiles .XTestGoFiles 
.IgnoredGoFiles) 0 }}'" bufio bytes [...]
template: main:2:14: executing "main" at <index (or .GoFiles ....>: error 
calling index: index out of range: 0
dh_golang: go list -f '\
{{ .Dir }}/{{ index (or .GoFiles .CgoFiles .TestGoFiles .XTestGoFiles 
.IgnoredGoFiles) 0 }}' returned exit code 1
make: *** [debian/rules:18: binary] Error 1
dpkg-buildpackage: error: fakeroot debian/rules binary subprocess returned exit 
status 2

The reason is that since gccgo-8, `go list {{ .Deps }}` will return
standard library. But it can't return the source files for standard
library. So the template will execute things like `index [] 0`.

Patch is attached.

-- 
Best regards,
Shengjing Zhu
>From 18c297db3557315a9ab844d1f6c4bdaceabbe987 Mon Sep 17 00:00:00 2001
From: Shengjing Zhu <i...@zhsj.me>
Date: Sat, 25 Aug 2018 23:57:58 +0800
Subject: [PATCH] Fix index out of range when list godeps sources

Signed-off-by: Shengjing Zhu <i...@zhsj.me>
---
 script/dh_golang | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/script/dh_golang b/script/dh_golang
index 73ded48..4dc66ab 100755
--- a/script/dh_golang
+++ b/script/dh_golang
@@ -77,7 +77,7 @@ my $tmpl = '{{ range .Deps }}{{.}}
 my @godeps = exec_single(qq{go list -f '$tmpl'}, @targets);
 
 my $gofiletmpl = '\
-{{ .Dir }}/{{ index (or .GoFiles .CgoFiles .TestGoFiles .XTestGoFiles .IgnoredGoFiles) 0 }}';
+{{ if $x := (or .GoFiles .CgoFiles .TestGoFiles .XTestGoFiles .IgnoredGoFiles) }}{{ .Dir }}/{{ index $x 0 }}{{ end }}';
 my @gofiles = exec_chunked(qq{go list -f '$gofiletmpl'}, uniq(@godeps));
 
 my @realpath;
-- 
2.18.0

Reply via email to