Skip to content

False positive U1000? #1372

@MaximMolchanov

Description

@MaximMolchanov

Let's say we have two files:

package main

func foo() int {
	return 0
}

func main() {
}

and

//go:build sometag

package main

import (
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestFoo(t *testing.T) {
	assert.Equal(t, 0, foo())
}

Is foo() unused?

$ staticcheck -f binary > tmp1
$ staticcheck -tags=sometag -f binary > tmp2
$ staticcheck -merge tmp1 tmp2
main.go:3:6: func foo is unused (U1000)

But is it?

We can move foo() to the second file, but is it correct to mark it as unused in such case? If yes, then why do we need merge at all?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions