laher / goxc

a build tool for Go, with a focus on cross-compiling, packaging and deployment
1.68k stars 79 forks source link

ldflags interpolation adds spurious quotes #91

Closed rasky closed 8 years ago

rasky commented 8 years ago

Hello, it looks like ldflags interpolation broke with Go 1.5. The symptom is that the interpolated string is surrounded by single quotes. For instance, I have a command line argument that simply prints the version number, and I get back this:

'1.0'

instead of:

1.0

Notice that I verified that the single quotes are actually being inserted in the final binary, so there's nothing happening in the application itself.

I run goxc -pv VERSION. Adding some debugging prints to the goxc source code, I got this dump of the command line call:

"/usr/local/Cellar/go/1.5.2/libexec/bin/go" []string{"build", "-ldflags", "-w -s -X main.BUILD_DATE='2015-12-10T17:46:58+01:00' -X main.VERSION='29' ", "-o", "/Users/rasky/Sources/go/src/myproject/.output/29/darwin-amd64", "."}

The single quotes are being added in buildFlags(). It doesn't seem this was recently changed, so I guess that it's the go binary that modified its behavior. I reproduce the same problem while running goxc on both darwin and linux.

The fix appears trivial (remove the quote escaping in buildFlags()) but I was wondering if there's more that misses the eye.

laher commented 8 years ago

thanks for reporting. It looks like a straightforward fix, yes. I'm flat-stick right now, but I'll get onto it soon. [pull-requests very welcome, though]

laher commented 8 years ago

@rasky please can you try with this branch: feature/remove-quotes-ldflags .

It seems to work OK, but I think I need to work out how to escape special characters.

The branch is in this PR: https://github.com/laher/goxc/pull/92

jhillyerd commented 8 years ago

Test & confirmed this fixes the problem on Go 1.6 for my setup: https://github.com/jhillyerd/inbucket/blob/1.1.0-rc1/.goxc.json

laher commented 8 years ago

OK thanks @jhillyerd . I merged that PR, #92