Avatar ·

Correct naming of packages for testing in Go (unit-testing)

Hello, colleagues! I'm new to Go and trying to figure out how to properly name packages for tests. I have a project with this structure: ``` myapp/ ├── internal/ │ ├── calculator/ │ │ ├── calc.go │ │ └── calc_test.go │ └── validator/ │ ├── valid.go │ └── valid_test.go ├── cmd/ │ └── main.go └── go.mod ``` Inside `calc.go` I have declared the package `package calculator`. In `calc_test.go` I also wrote `package calculator`, and the tests work. But I've seen that some developers use `package calculator_test` for test files. What's the difference? When should I use `_test` in the package name, and when should I not? I'm confused because when using `package calculator_test` I cannot access unexported functions and variables from the test.