assert

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2021 License: MIT Imports: 4 Imported by: 0

README

assert

package main

import (
	"log"

	"github.com/QisFj/godry/assert"
)

func main(){
    defer assert.Catch(func(violation assert.Violation) {
		// Catch Violation: <assertion violation>: xxx.go:123 1 == 2
        log.Printf("Catch Violation: %s", violation)
	})
    assert.Assert(1 == 2, "1 == 2", nil)
}

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(assert bool, message string, kvs map[string]interface{}, opts ...ViolationOpt)

func Catch

func Catch(handlers ...func(Violation))

func Int

func Int(v interface{}) int

func String

func String(v interface{}) string

func Uint

func Uint(v interface{}) uint

Types

type Assertion

type Assertion struct {
	Message string
	KVs     map[string]interface{}
}

func (Assertion) String

func (a Assertion) String() string

type Violation

type Violation struct {
	Position  string
	Assertion Assertion
}

func (Violation) String

func (v Violation) String() string

type ViolationOpt

type ViolationOpt func(violation *Violation)

this can be used to modify Violation object

func CallerOption

func CallerOption(deltaDepth int, shortName bool) ViolationOpt

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL