Skip to content

Is this unused false positive? #942

@hiromoon

Description

@hiromoon

Hi, I have a question.
Is this a false positive?

Static checker warns unused function.

$ golangci-lint run
foo/example.go:15:16: func `(*Buzz).bar` is unused (unused)
func (b *Buzz) bar() {

This private function is used through interface.

package main

import "./foo"

func main() {
	foo.Bar(&foo.Buzz{})
}
package foo

import "fmt"

type Foo interface {
	bar()
}

func Bar(f Foo) {
	f.bar()
}

type Buzz struct{}

func (b *Buzz) bar() {
	fmt.Println("foo bar buzz")
}

This problem happens with [email protected], not with [email protected].

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions