Skip to content

false deadcode positive for main_test.go files #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cloudlena opened this issue Jun 27, 2018 · 3 comments
Closed

false deadcode positive for main_test.go files #131

cloudlena opened this issue Jun 27, 2018 · 3 comments
Labels
false positive An error is reported when one does not exist

Comments

@cloudlena
Copy link

cloudlena commented Jun 27, 2018

deadcode produces false positives if there is a main_test.go file which is part of the main package. To reproduce, create the following files:

main.go:

package main

import "fmt"

func main() {
	fmt.Println("derp")
}

main_test.go:

package main

import (
	"fmt"
	"testing"
)

func TestMain(t *testing.T) {
	fmt.Println("herp")
}

This produces the following error message when running golangci-lint run:

main_test.go:8:6: `TestMain` is unused (deadcode)
func TestMain(t *testing.T) {
     ^

The false positive doesn't occur, if the package of the testing file is changed to main_test.

@jirfag jirfag added the false positive An error is reported when one does not exist label Jun 28, 2018
golangci pushed a commit that referenced this issue Jun 28, 2018
@jirfag
Copy link
Contributor

jirfag commented Jun 28, 2018

thank you for reporting!

jirfag added a commit that referenced this issue Jun 28, 2018
@jirfag
Copy link
Contributor

jirfag commented Jun 28, 2018

Fixed it

@jirfag jirfag closed this as completed Jun 28, 2018
@cloudlena
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false positive An error is reported when one does not exist
Projects
None yet
Development

No branches or pull requests

2 participants