Go Build tag - getting timestamp on Windows -


i have seen following command set build version

go build -ldflags "-x main.minversion `date -u +.%y%m%d%.h%m%s`" service.go 

but cant timestamp part work on windows !

i using go 1.5 following arguments...

build -i -ldflags "-x main.server_name=mffp -x main.version=1.0.0 -x main.build_date=`date -u +.%y%m%d%.h%m%s`" 

the error date part

is error system related? tried on windows?

thanks!

the command on *nix systems using backtick command substitution. date built-in on posix, , inside `s interpreted shell command , replaced value.

cmd.exe doesn't command substitution inside backticks @ all, there's ways accomplish same thing using for /f delims="", aka powerful command in windows shell, it's pretty hacky. maybe use powershell instead, supports $(command) syntax?

ps c:\users\adsmith> go build -i -ldflags "-x main.server_name=mffp -x main.version=1.0.0 -x main.build_date=$(get-date -uformat .%y%m%d%.h%m%s)" 

you might have play format -- i'm not sure that's supposed on posix. outputs:

.20160107.111641 // jan 7th 2016, 11:16:41 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -