https://github.com/tidwall/assert
An assert function for Go that works like the one in C.
https://github.com/tidwall/assert
Last synced: 7 months ago
JSON representation
An assert function for Go that works like the one in C.
- Host: GitHub
- URL: https://github.com/tidwall/assert
- Owner: tidwall
- License: mit
- Created: 2021-06-23T12:52:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-23T12:59:44.000Z (over 4 years ago)
- Last Synced: 2025-04-27T20:38:20.876Z (9 months ago)
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 21
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Assert
[](https://godoc.org/github.com/tidwall/assert)
This package provides an assert function for Go.
It's designed to work like [assert](https://man7.org/linux/man-pages/man3/assert.3.html) in C.
## Example
```go
package my_test
import "github.com/tidwall/assert"
func TestMyThing(t *testing.T) {
assert.Assert("hello" == "jello")
}
```
This will print the following message and abort the program.
```
Assertion failed: ("hello" == "jello"), function TestMyThing, file my_test.go, line 6.
```