Skip to content

package-directory-mismatch: false positive for main_test #1532

@wolfvictorCHI

Description

@wolfvictorCHI

Describe the bug
revive's package-directory-mismatch reports a false positive for the usage of the package main_test on the test file main_test.go related to main.go.

To Reproduce
Steps to reproduce the behavior:

  1. I updated revive go install github.com/mgechev/revive@latest
  2. I run it with the following flags & configuration file:
revive -config myservice/reviveconfig.toml myservice/main_test.go
enableAllRules = true

Expected behavior
I expect package main_test to be accepted by revive without throwing a warning.

Logs
revive's output: myservice/main_test.go:1:9: package name "main_test" does not match directory name "myservice".

Desktop (please complete the following information):

  • OS: macOS 15.6.1 (24G90)
  • Go 1.25.1

Additional context
revive seems to only detect this as an error when running it from outside the directory. If I run it on the directory, then it does not detect main_test as a violation of package-directory-mismatch.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions