For archive's sake, let me tell my solution.

I carefully added a preprocessing command into my build steps. Before 
compiling, the following command is run:

sed -E -i 's:(Version\s*=\s*)".*":\1"'$(DOCKER_CLI_VERSION)'":'  \
        $(@D)/cli/version/version.go \
    && sed -E -i 's:(GitCommit\s*=\s*)".*":\1"'$(shell git rev-parse 
--short HEAD)'":'  \
        $(@D)/cli/version/version.go

The regexes match patterns in 

    Version    =  "xxx"

Format and replaces the string inside the double quotes while keeping all 
the whitespaces and other relevant characters intact, so repeatedly calling 
the same substitution is safe and does the expected thing. Same for the 
GitCommit, except it uses a shell command instead of an environment 
variable.

Happy Hacking
Atilla

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/708d9e10-5e79-4bea-9504-c1a1de0c8640o%40googlegroups.com.

Reply via email to