https://github.com/zanzythebar/assert-lib
A lightweight assertion library for Go.
https://github.com/zanzythebar/assert-lib
assert assertions assertions-library go golang systems-programming
Last synced: 6 months ago
JSON representation
A lightweight assertion library for Go.
- Host: GitHub
- URL: https://github.com/zanzythebar/assert-lib
- Owner: ZanzyTHEbar
- License: mit
- Created: 2024-10-15T16:15:20.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-10-29T13:21:16.000Z (12 months ago)
- Last Synced: 2025-01-31T09:32:17.885Z (8 months ago)
- Topics: assert, assertions, assertions-library, go, golang, systems-programming
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Assert Go
A lightweight assertion library for Go, designed for systems and real-time programming with structured logging and flush controls.
## Installation
```bash
go get github.com/ZanzyTHEbar/assert-lib
```## Usage
```go
package mainimport (
"context"
"github.com/ZanzyTHEbar/assert-lib"
)func main() {
handler := assert.NewAssertHandler()
handler.Assert(context.TODO(), false, "This should fail")
}
```Check out the [examples](/examples/) directory for usage examples.
## Features
- **Assertions**: Assert, Nil, NotNil, NoError, Never.
- **Flush Management**: Control output flushes with AssertFlush.
- **Context-Based Logging**: Attach structured logging to your assertion calls.
- **Custom Loggers**: Use your own logger with the AssertHandler interface.Works very well with my [errbuilder-go](https://github.com/ZanzyTHEbar/errbuilder-go) library.
## Examples
```bash
go run examples/basic_assertion.go
go run examples/deferred_assertions.go
go run examples/custom_exit.go
go run examples/formater.go
```