An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# Assert

[![GoDoc](https://godoc.org/github.com/tidwall/assert?status.svg)](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.
```