【问题标题】:GitHub Actions: Run golint on wihdowsGitHub Actions:在 Windows 上运行 golang
【发布时间】:2020-04-01 19:58:44
【问题描述】:

我想在 GitHub Actions 中的 windows 上运行 golint。

go install golang.org/x/lint/golint
golint ./...

但是我遇到了这个错误:

golint : The term 'golint' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\a\_temp\dd1f47cc-42be-445e-9300-b2b5fbfd04da.ps1:4 char:1
+ golint ./...
+ ~~~~~~
+ CategoryInfo          : ObjectNotFound: (golint:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException

##[error]Process completed with exit code 1.

接下来我该怎么做?

这是我下面的.github/workflows/test.yaml。这在 Ubuntu 和 Mac 上运行良好。

name: test
on:
  push:
    branches:
    - "**"
jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
        - ubuntu-latest
        - macOS-latest
        - windows-latest
    steps:
    - name: setup env unix
      run: |
        echo ::set-env name=GOPATH::${{ runner.workspace }}
        echo ::add-path::${{ runner.workspace }}/bin
      if: "matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'"
    - name: setup env windows
      run: |
        echo ::set-env name=GOPATH::${{ runner.workspace }}
        echo ::add-path::${{ runner.workspace }}\bin
      if: "matrix.os == 'windows-latest'"
    - name: setup go
      uses: actions/setup-go@v1
      with:
        go-version: 1.x
    - name: checkout
      uses: actions/checkout@v1
      with:
        fetch-depth: 1
        path: src/github.com/${{ github.repository }}
    - name: golint
      run: |
        go env
        go install golang.org/x/lint/golint
        golint ./...

这是最小的存储库:https://github.com/sanemat/use-golint-on-windows 这是拉取请求:https://github.com/sanemat/use-golint-on-windows/pull/2

【问题讨论】:

    标签: windows powershell go github-actions golint


    【解决方案1】:

    正如another (deleted) answer 提到的,这是一个路径问题。

    改用此工作流程:

    name: test
    on:
      push:
        branches:
        - "**"
    jobs:
      test:
        runs-on: ${{ matrix.os }}
        strategy:
          fail-fast: false
          matrix:
            os:
            - ubuntu-latest
            - macOS-latest
            - windows-latest
        steps:
        - name: setup go
          uses: actions/setup-go@v1
          with:
            go-version: 1.x
        - name: setup env
          run: |
            echo "::set-env name=GOPATH::$(go env GOPATH)"
            echo "::add-path::$(go env GOPATH)/bin"
          shell: bash
        - name: checkout
          uses: actions/checkout@v1
          with:
            fetch-depth: 1
            path: src/github.com/${{ github.repository }}
        - name: golint
          run: |
            go env
            go install golang.org/x/lint/golint
            golint ./...
    

    【讨论】:

      猜你喜欢
      • 2020-08-16
      • 2021-05-09
      • 1970-01-01
      • 2020-05-13
      • 1970-01-01
      • 2021-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多