How to add paramters to the go install call

Asked by imker

Hello,

with some try and error I figured out how I can build my project with dh-golang. But now I struggle with some details.

As far as I can see from my logs when dh_auto_build calls the "go install" command the following parameters are added automatically "-trimpath -v -p N". But for some reason I also need to add -ldflags "-X main.Version=x.y.z" to this call.

From the docs I understand that dpkg-buildflags is somehow involved into this process, but I don't understand how to map the given examples to golang.

I gues I need to export a DEB_flag_APPEND variable. But I can't see witch one, and I'm also not sure what the value should be. "-ldflags \"-X...." or just "-X ..."

Thanks for your help.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu dh-golang Edit question
Assignee:
No assignee Edit question
Solved by:
imker
Solved:
Last query:
Last reply:
Revision history for this message
imker (imker) said :
#1

Hello again,

after I read the code of dh-golang I figured out how I can do this in debian/rules, see below:

override_dh_auto_build:
 dh_auto_build -- -ldflags="-X main.Version=x.y.z"

Why this works?
dh_auto_build will give everything behind the "--" through to dh-golang build function. And dh-golang build will add all parameters it got in that way to the build command.

The only question left is, why there is no environment variable defined for that propose in dh-golang, like most other debhelper build system do provide?

Have a nice day
Imker

Revision history for this message
imker (imker) said :
#2

Hello again,

after I read the code of dh-golang I figured out how I can do this in debian/rules, see below:

override_dh_auto_build:
 dh_auto_build -- -ldflags="-X main.Version=x.y.z"

Why this works?
dh_auto_build will give everything behind the "--" through to dh-golang build function. And dh-golang build will add all parameters it got in that way to the build command.

The only question left is, why there is no environment variable defined for that propose in dh-golang, like most other debhelper build system do provide?

Have a nice day
Imker