In Go you can detect race conditions by adding the -race argument:
DeepEqual
For `slices` & friends you can use `reflect.DeepEqual` to compare
variables in tests
TableDrivenTests
Writing good tests is not trivial, but in many situations a lot of
ground can be covered with table-driven
tests: Each table
entry is a complete test case with inputs and expected results, and
sometimes with additional information such as a test name to make the
test output easily readable. If you ever find yourself using copy and
paste when writing a test, think about whether refactoring into a
table-driven test or pulling the copied code out into a helper function
might be a better option.
Given a table of test cases, the actual test simply iterates through all
table entries and for each entry performs the necessary tests. The test
code is written once and amortized over all table entries, so it makes
sense to write a careful test with good error messages.
Fatals
Sometimes you want to throw fatal errors in tests to prevent problems,
for example in case `nil` is returned and you need to do stuff with
the return value in later tests: