
Company News
Andrew Becherer Joins Socket as Chief Information Security Officer
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.
Assertions for the standard testing package.
assert is a minimalistic replacement for the stretchr/testify package,
providing an alternative API to switch between t.Errorf() and t.Fatalf():
instead of using separate packages (assert/require), it abuses type parameters:
assert.Equal[E](t, 1, 2) // [E] for t.Errorf()
assert.Equal[F](t, 1, 2) // [F] for t.Fatalf()
Go 1.21+
go get go-simpler.org/assert
[!tip] When developing a library, you may want to keep
go.modsmall (or, even better, empty). In such cases, it is recommended to just copy-pasteassert, as it is tiny and rarely updated. See thecmd/cputility to do this automatically.
The EF subpackage should be dot-imported so that E and F can be used as local types:
"go-simpler.org/assert"
. "go-simpler.org/assert/EF"
Optional format and arguments can be provided to each assertion to customize the error message:
assert.Equal[E](t, 1, 2, "%d != %d", 1, 2) // prints "1 != 2"
Asserts that two values are equal.
assert.Equal[E](t, 1, 2)
Asserts that the error is nil.
assert.NoErr[E](t, err)
Asserts that errors.Is(err, target) is true.
assert.IsErr[E](t, err, os.ErrNotExist)
Asserts that errors.As(err, target) is true.
assert.AsErr[E](t, err, new(*os.PathError))
Asserts that the given function panics with the argument v.
assert.Panics[E](t, func() { /* panic? */ }, 42)
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.