Using an environment variable

marceloschr's Avatar

marceloschr

14 Sep, 2018 02:45 PM

So, I am trying to pass linker flags to the go compiler, I have tested this locally and it did work:

go build -o uwunote.exe -ldflags "-H windowsgui -X github.com/UwUNote/uwunote/internal/updates.AppVersion=$(git describe --tags --always --dirty)"

but it didn't work on AppVeyor, so I tried it using an environment variable:

  - $env:UWU_VERSION=git describe --tags --always --dirty
  - go build -o uwunote.exe -ldflags "-H windowsgui -X github.com/UwUNote/uwunote/internal/updates.AppVersion=$env:UWU_VERSION"

Same story, doesn't work on AppVeyor, but locally it does.
I get the following output:

$env:UWU_VERSION=git describe --tags --always --dirty
The filename, directory name, or volume label syntax is incorrect.
Command exited with code 1
  1. Support Staff 1 Posted by Owen McDonnell on 14 Sep, 2018 05:21 PM

    Owen McDonnell's Avatar

    By default, lines in appveyor.yml are interpreted by cmd which does not recognize $env: syntax.
    To use powershell to interpret lines change to

      - ps: $env:UWU_VERSION=git describe --tags --always --dirty
      - ps: go build -o uwunote.exe -ldflags "-H windowsgui -X github.com/UwUNote/uwunote/internal/updates.AppVersion=$env:UWU_VERSION"
    
  2. 2 Posted by marceloschr on 14 Sep, 2018 08:04 PM

    marceloschr's Avatar

    Thanks!

  3. Owen McDonnell closed this discussion on 15 Sep, 2018 05:17 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac