typeassert

package
v0.0.0-...-0ce9163 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

README

package typeassert

import "github.com/vivint/rothko/internal/typeassert"

package typeassert provides helper functions type asserting structures.

Usage

type Asserter
type Asserter struct {
}

Asserter helps type assertions with an "all-or-nothing" style API.

func A
func A(x interface{}) *Asserter

A wraps the value in an Asserter.

func (*Asserter) Bool
func (a *Asserter) Bool() bool

Bool asserts the value as a bool.

func (*Asserter) Err
func (a *Asserter) Err() error

Err returns an error if any of the assertions failed. If the error is not nil, none of the assertions are valid.

func (*Asserter) Float64
func (a *Asserter) Float64() float64

Float64 asserts the value as a float64.

func (*Asserter) I
func (a *Asserter) I(index string) *Asserter

I indexes into a map[string]interface{}.

func (*Asserter) Int
func (a *Asserter) Int() int

Int asserts the value as an int.

func (*Asserter) Int64
func (a *Asserter) Int64() int64

Int64 asserts the value as an int64.

func (*Asserter) N
func (a *Asserter) N(index int) *Asserter

N indexes into a []interface{}.

func (*Asserter) String
func (a *Asserter) String() string

String asserts the value as a string.

func (*Asserter) V
func (a *Asserter) V() interface{}

V returns the current value pointed at by the Asserter.

Documentation

Overview

package typeassert provides helper functions type asserting structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asserter

type Asserter struct {
	// contains filtered or unexported fields
}

Asserter helps type assertions with an "all-or-nothing" style API.

func A

func A(x interface{}) *Asserter

A wraps the value in an Asserter.

func (*Asserter) Bool

func (a *Asserter) Bool() bool

Bool asserts the value as a bool.

func (*Asserter) Err

func (a *Asserter) Err() error

Err returns an error if any of the assertions failed. If the error is not nil, none of the assertions are valid.

func (*Asserter) Float64

func (a *Asserter) Float64() float64

Float64 asserts the value as a float64.

func (*Asserter) I

func (a *Asserter) I(index string) *Asserter

I indexes into a map[string]interface{}.

func (*Asserter) Int

func (a *Asserter) Int() int

Int asserts the value as an int.

func (*Asserter) Int64

func (a *Asserter) Int64() int64

Int64 asserts the value as an int64.

func (*Asserter) N

func (a *Asserter) N(index int) *Asserter

N indexes into a []interface{}.

func (*Asserter) String

func (a *Asserter) String() string

String asserts the value as a string.

func (*Asserter) V

func (a *Asserter) V() interface{}

V returns the current value pointed at by the Asserter.

Jump to

Keyboard shortcuts

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