go get exits with status code 1 in Windows pwsh.

I decided to use “pwsh” for cross-compatibility when building on Linux and Windows. However, in Windows, go get does fail with status code 1. I guess it’s associated with underlying git. Anybody has an idea?

workflow.yml:

name: CI/CD

on: [push]

jobs:
  build:
    name: BUILD / ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        go: ['1.13']

    steps:
      - name: Pull the source code.
        uses: actions/checkout@v1

      - name: Prepare Go toolchain.
        uses: actions/setup-go@v1
        with:
          go-version: ${{ matrix.go }}

      - name: Install libasound2-dev on Linux.
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends libasound2-dev

      - name: Build executable.
        shell: pwsh
        working-directory: cmd/macrosphere
        run: |
          # MACROSPHERE="macrosphere_`go env GOOS`_`go env GOARCH``go env GOEXE`"
          $MACROSPHERE="macrosphere_"+(go env GOOS)+"_"+(go env GOARCH)+(go env GOEXE)

          # ZIP_PASS=`uuidgen -r | tr -d '-'`
          $ZIP_PASS=(New-Guid).ToString() -replace '-', ''

          # Install statik executable.
          go get github.com/rakyll/statik

          # Embed assets with statik as a package.
          go generate -x

          # Build.
          go build -x -trimpath -ldflags="-w -s" -o="$MACROSPHERE"

          # Compress.
          7z a "$MACROSPHERE.zip" -p"$ZIP_PASS" "$MACROSPHERE"

          # Upload.
          curl -F file=@$MACROSPHERE.zip https://0x0.st

          # echo -e "\nZIP Password: $ZIP_PASS"
          echo "`nZIP Password: $ZIP_PASS"

Thanks for your feedback! I can repro this and has raised an internal ticket for tracking, will update once there is a response.

1 Like

if you confirmed go is returning exit code 1, then it sounds like an issue with go?

Hi @0xbkt,

It looks output of pwsh with go lang cannot execute successfully, please split your build steps apart, it works on my end. Code sample as below:

steps:
      - name: Pull the source code.
        uses: actions/checkout@v1

      - name: Prepare Go toolchain.
        uses: actions/setup-go@v1
        with:
          go-version: ${{ matrix.go }}

      - name: Install libasound2-dev on Linux.
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends libasound2-dev
      - name: set VAR
        shell: pwsh
        run: |
          # MACROSPHERE="macrosphere_`go env GOOS`_`go env GOARCH``go env GOEXE`"
          $MACROSPHERE="macrosphere_"+(go env GOOS)+"_"+(go env GOARCH)+(go env GOEXE)
          $ZIP_PASS=(New-Guid).ToString() -replace '-', ''
          echo $ZIP_PASS
      - name: Build executable.
        shell: pwsh
        #working-directory: cmd/macrosphere
        run: |
          go get github.com/rakyll/statik
          go generate -x
      - name: Build
        shell: pwsh
        run: |
          go build -x -trimpath -ldflags="-w -s" -o="$MACROSPHERE"

      - name: 7z
        shell: pwsh
        run: |
          7z a "$MACROSPHERE.zip" -p"$ZIP_PASS" "$MACROSPHERE"
      - name: Upload
        shell: pwsh
        run: |
          curl -F file=@$MACROSPHERE.zip https://0x0.st
          echo "`nZIP Password: $ZIP_PASS"

Note: there still is an error for 7z step for only window os, but it should be related the command itself but not github.