简体   繁体   English

GitHub 操作:在 wihdows 上运行 golint

[英]GitHub Actions: Run golint on wihdows

I want to run golint on windows in GitHub Actions.我想在 GitHub Actions 中的 Windows 上运行 golint。

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

But I met this error:但我遇到了这个错误:

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.

What do I do next?我接下来该怎么做?

This is my .github/workflows/test.yaml below.这是我的.github/workflows/test.yaml下面。 This works well on Ubuntu and Mac.这在 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 ./...

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

As another (deleted) answer mentioned, this is a PATH issue.正如提到的另一个(已删除)答案,这是一个 PATH 问题。

Use this workflow instead:请改用此工作流程:

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 ./...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM