Looks like more boilerplate to me.
Re:How to start a Go project in 2023
by SPascareli13 on Tuesday May 23, 2023 @07:12PM
(#36052012)
I made this mistake in a project at work...never again.
Re:How to start a Go project in 2023
by mparnisari on Thursday May 25, 2023 @12:55PM
(#36073114)
The mistake of using build tags, or the mistake of not using them?
Re:How to start a Go project in 2023
by SPascareli13 on Friday May 26, 2023 @10:06PM
(#36091422)
Using them.
Personally I like putting them in the tests, with t.Skip (frequently further in the code, in whatever sets up test dependencies that makes it an "integration" test, so it's automatically skipped).
That way you can blend unit and integration in the same package.
Re:How to start a Go project in 2023
by Scotch3297 on Wednesday May 24, 2023 @04:25AM
(#36055408)
Well, you can configure your editor to lint your test files with build tags and that's the end of the issue. At least on VSCode and Goland you can. I think it's way cleaner to have your integration tests with a build tag rather than this extra piece of code.
If you don't have tests all over the place and you are moderately organized with your folder structure, there is no reason why build tags should represent a discoverability issue.
Along with the issues listed here you will run into issues with editors not building/linting your tests files because they have build tags that the editor is unaware of.
You can also put the environment variable in a TestMain[1] to cover an entire package of integration tests:
[1] https://pkg.go.dev/testing#hdr-Main