Cloud-builders: Baffling behavior of args when building go binary

Created on 19 Oct 2017  路  2Comments  路  Source: GoogleCloudPlatform/cloud-builders

Hi all,

The following works:

steps:
- name: 'gcr.io/cloud-builders/go'
  args: ['build', '-o', 'main', '-v', '-ldflags', '"-d"', '-a', '.']

But adding an additional flag to -ldflags does not:

steps:
- name: 'gcr.io/cloud-builders/go'
  args: ['build', '-o', 'main', '-v', '-ldflags', '"-d -w"', '-a', '.'] # Added -w flag in flag list

returns flag provided but not defined: -d -w But the -w flag is listed...

Is this expected behaviour? What is the alternative?

Most helpful comment

Instead of '"-d -w"', use '-d -w'. The quotes you provided are to help the shell figure out that -d and -w go together, but inside cloud build there is no actual shell - just the yaml parser, so '-d -w' is sufficient.

All 2 comments

Instead of '"-d -w"', use '-d -w'. The quotes you provided are to help the shell figure out that -d and -w go together, but inside cloud build there is no actual shell - just the yaml parser, so '-d -w' is sufficient.

Interesting. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DazWilkin picture DazWilkin  路  3Comments

drgomesp picture drgomesp  路  8Comments

acasademont picture acasademont  路  4Comments

maxpaynestory picture maxpaynestory  路  7Comments

DocBradfordSoftware picture DocBradfordSoftware  路  7Comments