Difference between main.go and main_test.go

Hi,

I am referring to https://github.com/hashicorp/terraform/. Can someone help me with the difference between main.go and main_test.go? Any examples to understand it better.

Best Regards,

Kaushal

Hi @kaushalshriyan,

Files with names ending in _test.go are part of the Go programming language testing convention implemented by the go test command.

Reading the How to Write Go Code guide will hopefully put these different parts in perspective, but the short answer is that main.go is part of the main Terraform application and happens to contain the entry point function, while main_test.go is just one of many files that form Terraform’s test suite, with that one testing some of the helper functions in main.go.