subset

package
v0.37.4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package subset implements functions to check if one value is a subset of another.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(source, target interface{}) error

Assert checks whether target is a subset of source. source and target must be the same type. target is a subset of source when:

  • If target and source are slices or arrays, then target must have the same number of elements as source. Each element in target must be a subset of the corresponding element from source.

  • If target and source are maps, each key in source must exist in target. The value for each element in target must be a subset of the corresponding element from source.

  • Otherwise, target and source must be deeply equal.

An instance of Error will be returned when target is not a subset of source.

Subset checking is primarily useful when doing things like YAML assertions, where you only want to ensure that a subset of YAML is defined as expected.

func YAMLAssert

func YAMLAssert(source, target []byte) error

YAMLAssert is like Assert but accepts YAML bytes as input.

Types

type Error

type Error struct {
	Message string // Message of the error
	Inner   error  // Optional inner error
}

Error is a subset assertion error.

func (*Error) Error

func (e *Error) Error() string

Error implements error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the inner error, if set.

Jump to

Keyboard shortcuts

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