must

package module
v0.0.0-...-e840765 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 2 Imported by: 3 modules, 9 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-must

simple go assertion package

By v-braun - viktor-braun.de.

Build Status codecov PR welcome

Installation

go get github.com/v-braun/go-must

Usage


// if val == nil will panic with "argument val is nil"
must.ArgNotNil(val, "val") 

// if val <= 1 will panic with val invalid: (0 > 1) == false
must.ArgBeValid(val > 1, "val invalid: (%d > 1) == false", val)

Authors

image
v-braun

Contributing

Make sure to read these guides before getting started:

License

go-must is available under the MIT License. See LICENSE for details.

Documentation

Overview

Package must is a simple assertion package for go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgBeValid

func ArgBeValid(valid bool, message string, a ...interface{})

ArgBeValid checks the given expression and if it returns true it will panics with the given message and format args

func ArgNotNil

func ArgNotNil(item interface{}, name string)

ArgNotNil panics if item is nil. The error will be 'argument {name} is nil'

func BeFalse

func BeFalse(expr bool, message string, a ...interface{})

func BeTrue

func BeTrue(expr bool, message string, a ...interface{})

func NoError

func NoError(err error, message string, a ...interface{})

NoError panics when error is not nil

Types

This section is empty.

Jump to

Keyboard shortcuts

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