Skip to content

Add gofmt check in workflows #563

Closed
Closed
@Xuanwo

Description

@Xuanwo

We need to add gofmt check to make sure every PR has been formatted.

Like https://github.com/digitalocean/godo/pull/396/files

We should add the following action .github/workflows/gofmt.yml in every golang related repos:

name: "gofmt"

on: [ push,pull_request ]

jobs:
  gofmt:
    name: gofmt
    runs-on: ubuntu-latest

    steps:
      - name: Set up Go 1.x
        uses: actions/setup-go@v2
        with:
          go-version: "1.15"

      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Format
        run: if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then exit 1; fi

Tips:

  • Should be make build, as make build will format all code.

Todo Lists

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions