snip

package
v0.0.0-...-1d067d0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package equal provides a deep equivalence relation for arbitrary values. package equal

Example (Equal)
//!+
fmt.Println(Equal([]int{1, 2, 3}, []int{1, 2, 3}))        // "true"
fmt.Println(Equal([]string{"foo"}, []string{"bar"}))      // "false"
fmt.Println(Equal([]string(nil), []string{}))             // "true"
fmt.Println(Equal(map[string]int(nil), map[string]int{})) // "true"
//!-
Output:

true
false
true
true
Example (EqualCycle)
//!+cycle
// Circular linked lists a -> b -> a and c -> c.
type link struct {
	value string
	tail  *link
}
a, b, c := &link{value: "a"}, &link{value: "b"}, &link{value: "c"}
a.tail, b.tail, c.tail = b, a, c
fmt.Println(Equal(a, a)) // "true"
fmt.Println(Equal(b, b)) // "true"
fmt.Println(Equal(c, c)) // "true"
fmt.Println(Equal(a, b)) // "false"
fmt.Println(Equal(a, c)) // "false"
//!-cycle
Output:

true
true
true
false
false

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(x, y interface{}) bool

!+comparison Equal reports whether x and y are deeply equal. !-comparison

Map keys are always compared with ==, not deeply. (This matters for keys containing pointers or interfaces.) !+comparison

func Icon

func Icon(name string) image.Image

Concurrencysafe.

func IconI

func IconI(name string) image.Image

Concurrencysafe.

Types

type Bool

type Bool bool

-- bool Value

func NewBool

func NewBool(val bool, p *bool) *Bool

func (*Bool) Get

func (b *Bool) Get() interface{}

func (*Bool) Set

func (b *Bool) Set(s string) error

func (*Bool) String

func (b *Bool) String() string

type Duration

type Duration time.Duration

-- time.Duration Value

func NewDuration

func NewDuration(val time.Duration, p *time.Duration) *Duration

func (*Duration) Get

func (d *Duration) Get() interface{}

func (*Duration) Set

func (d *Duration) Set(s string) error

func (*Duration) String

func (d *Duration) String() string

type Float

type Float float64

-- float64 Value

func NewFloat

func NewFloat(val float64, p *float64) *Float

func (*Float) Get

func (f *Float) Get() interface{}

func (*Float) Set

func (f *Float) Set(s string) error

func (*Float) String

func (f *Float) String() string

type FuncMap

type FuncMap = template.FuncMap

type Int

type Int int

-- int Value

func NewInt

func NewInt(val int, p *int) *Int

func (*Int) Get

func (i *Int) Get() interface{}

func (*Int) Set

func (i *Int) Set(s string) error

func (*Int) String

func (i *Int) String() string

type Int64

type Int64 int64

-- int64 Value

func NewInt64

func NewInt64(val int64, p *int64) *Int64

func (*Int64) Get

func (i *Int64) Get() interface{}

func (*Int64) Set

func (i *Int64) Set(s string) error

func (*Int64) String

func (i *Int64) String() string

type String

type String string

-- string Value

func NewString

func NewString(val string, p *string) *String

func (*String) Get

func (s *String) Get() interface{}

func (*String) Set

func (s *String) Set(val string) error

func (*String) String

func (s *String) String() string

type Template

type Template = template.Template

type Uint

type Uint uint

-- uint Value

func NewUint

func NewUint(val uint, p *uint) *Uint

func (*Uint) Get

func (i *Uint) Get() interface{}

func (*Uint) Set

func (i *Uint) Set(s string) error

func (*Uint) String

func (i *Uint) String() string

type Uint64

type Uint64 uint64

-- uint64 Value

func NewUint64

func NewUint64(val uint64, p *uint64) *Uint64

func (*Uint64) Get

func (i *Uint64) Get() interface{}

func (*Uint64) Set

func (i *Uint64) Set(s string) error

func (*Uint64) String

func (i *Uint64) String() string

type Value

type Value interface {
	String() string
	Set(string) error
	Get() interface{}
}

Value is the interface to a dynamic value.

Hint: All implentations provide a New function, which takes two arguments - an initial default content - a go pointer variable (typially created by var ...) to hold and access the content

Note: All implentations should also provide a Let method which receives the represented type.

Jump to

Keyboard shortcuts

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