Skip to content

Support golangci-lint fmt --diff #1304

@MadLittleMods

Description

@MadLittleMods

Welcome

  • Yes, I understand that the GitHub action repository is not the repository of golangci-lint itself.
  • Yes, I've searched similar issues on GitHub and didn't find any.

Your feature request related to a problem? Please describe.

Support golangci-lint fmt --diff

In #1245, the claim is that golangci-lint run will run the same formatters that golangci-lint fmt would but I don't think that is true based on my experience.

Testing strategy:

  1. (using the default/standard config)
  2. First auto-fixing my codebase with go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 run ./... --fix
  3. go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 run ./... now passes
  4. But go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 fmt ./... changes even more things. (--diff also shows the changes)

Describe the solution you'd like.

Add an option to check that there are no additional changes from auto-formatters (golangci-lint fmt --diff)

Describe alternatives you've considered.

jobs:
  lint-go:
    name: Lint Go
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

      - name: Setup go
        uses: actions/setup-go@be3c94b385c4f180051c996d336f57a34c397495 # v3.6.1
        with:
          go-version: "stable"

      - name: Run golangci-lint (lint)
        run: go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.1 run ./... --max-issues-per-linter=0

      - name: Run golangci-lint (format)
        run: go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.1 fmt ./... --diff

Additional context.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions