Skip to content

Commit ef13eed

Browse files
committed
better docs for assert
1 parent 0e14aab commit ef13eed

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

assert/doc.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ all assert violations in the unit tests as well:
2525
assert.That(c.isLeaf(invitersKey), "only leaf can invite")
2626
2727
If some assertion violation occurs in the deep call stack, they are still
28-
reported as a test failure. See the above code blocks. If assertion failure
28+
reported as test failures. See the above code blocks. If assertion failure
2929
happens somewhere inside the Invite function's call stack, it's still reported
3030
correctly as a test failure of the TestInvite unit test. It doesn't matter how
3131
deep the recursion is or if parallel test runs are performed. The failure report
@@ -35,12 +35,14 @@ chapter.
3535
# Call Stack Traversal During Tests
3636
3737
The Assert package allows us to track assertion violations over the package and
38-
even module boundaries. When an assertion fails during the unit testing, the
39-
whole call stack is brought to unit test logs. And some help with your IDE, such
40-
as transferring output to a location list, for example, in Neovim/Vim. For
41-
example, you can find a proper test result parser like [nvim-go] (fork)
38+
module boundaries. When an assertion fails during the unit testing, the whole
39+
call stack is brought to unit test logs. And some help with your IDE, such as
40+
transferring output to a location list in Neovim/Vim. For example, you can find
41+
a compatible test result parser for Neovim from this plugin [nvim-go] (fork).
4242
43-
With a sizeable multi-repo environment, this has proven to be valuable.
43+
The call stack traversal has proven to be very valuable for package and module
44+
development in Go, especially when following TDD and fast development feedback
45+
cycles.
4446
4547
# Why Runtime Asserts Are So Important?
4648
@@ -52,12 +54,12 @@ raise up quality of our software.
5254
The assert package offers a convenient way to set preconditions to code which
5355
allow us detect programming errors and API violations faster. Still allowing
5456
production-time error handling if needed. And everything is automatic. You can
55-
set gorountinen specific asserter with [PushAsserter] function.
57+
set goroutine specific asserter with [PushAsserter] function.
5658
57-
You can set the assert package's default asserter with [SetDefault] or
58-
-asserter flag if Go's flag package is in use. This allows developer, operator
59-
and every-day user share the exact same binary but get the error messages and
60-
diagnostic they need.
59+
The assert package's default asserter you can set with [SetDefault] or -asserter
60+
flag if Go's flag package (or similar) is in use. This allows developer,
61+
operator and every-day user share the exact same binary but get the error
62+
messages and diagnostic they need.
6163
6264
// Production asserter adds formatted caller info to normal errors.
6365
// Information is transported thru error values when err2.Handle is in use.

0 commit comments

Comments
 (0)