1

I have enabled unparam linter in my config but its not detecting any warnings for my code

This shows for unparam when I run golangci-lint linters:

Enabled by your configuration linters: unparam: Reports unused function parameters [fast: false, auto-fix: false]

Here's my config:

run:
  modules-download-mode: readonly

linters-settings:
  unparam:
    check-exported: true    # Check for exported functions

linters:
  disable-all: true
  enable:
    - unparam

My main.go file:

/ Example function with an unused parameter
func ExampleFunc(x int, y string) {
    fmt.Println(y)  // Using y, so it's not reported as unused
}

func main() {
    // Calling the function with only one argument
    myString:="Hello" 
    myInt:=42

    ExampleFunc(myInt,myString)
}

When i run golangci-lint run,it doesn't show any errors.My golangci version is 1.56.2 and os is Mac.

3
  • 1
    The particular linter rule has some exceptions to avoid false positives, take a look at github.com/mvdan/unparam Commented Feb 22, 2024 at 5:05
  • Can you try with an older version of golanci and see if the same config works on the same code? Commented Feb 22, 2024 at 5:07
  • I tried with v1.54.2 and v1.53.2 but still doesn't work Commented Feb 22, 2024 at 5:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.