Arafath, that's kind of what I did (except I replaced the git command with my setversion.exe). It worked as expected... thank you!
On Friday, January 27, 2017 at 12:43:01 AM UTC-6, Arafath M wrote: > > Hi Eric, > > Under Windows, create a bat file with following contents. It uses latest > tag from git repo as version. > > echo Rebuilding App... > for /f %%i in ('git describe --tags ') do set version=%%i > go install -a -v -ldflags "-X main.versionBuild=%version%" > > > > Sincerely, > Arafath M > > On Fri, Jan 27, 2017 at 11:27 AM, Eric Brown <edb...@gmail.com > <javascript:>> wrote: > >> Got it to work as intended under Linux; however, compiling on Windows is >> a no-go. Perhaps I have to create a script, pass the output to a variable, >> and insert the variable into the build command? Hopefully not, so if >> anybody has any suggestions... it would be highly appreciated. Thanks! >> >> >> On Thursday, January 26, 2017 at 9:58:49 PM UTC-6, Eric Brown wrote: >>> >>> Using -ldflags -X, is there a way to set the internal value as the >>> output of an executable console file? >>> >>> I've seen examples like this: >>> >>> "-X main.githash=`git rev-parse HEAD`" (which would put the result of the >>> git command w/ flags into it) >>> >>> >>> however, I just can't get it to work (if it's even possible). >>> >>> The file I use is called setVersion.exe and does all the formatting, >>> etc. for me (which includes connecting to a ntp atomic time server for the >>> time stamp, etc.). >>> >>> What I'm using is (setVersion being included in the PATH environment): >>> >>> go build -ldflags "-X 'main.versionBuild=setVersion'" >>> >>> I've tried putting the quotations in different places, etc. Nothing I >>> try is working. >>> >> -- >> 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...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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. For more options, visit https://groups.google.com/d/optout.