stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
22.5k stars 1.56k forks source link

assert: make tHelper a type alias #1562

Closed dolmen closed 4 months ago

dolmen commented 4 months ago

Summary

The tHelper interface is defined only for internal usage. We don't need a "hard" type for it as we don't define methods on it. Let's make is just a alias to the anonymous interface it represents.

Note: we are already using type aliases elswhere, and type aliases were introduced a long time ago in Go 1.9.

Changes

Motivation

The tHelper symbol is not needed at runtime. This should reduce resource usage (yes, negligible).

Related issues

dolmen commented 4 months ago

@brackendawson There is no significant performance improvement (or degradation) expected. The resource usage I claim is just the absence of the type definition in the final binary, so a smaller binary.

Compare the output of this command on this branch vs master:

$ (cd assert ; go test -c && strings assert.test | grep BoolAssertionFunc)