example

package
Version: v0.0.0-...-a7167af Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MyMap

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

MyMap will be exported

MyMap is an immutable type and has the following template:

map[string]*MySlice

func NewMyMap

func NewMyMap(inits ...func(m *MyMap)) *MyMap

func NewMyMapCap

func NewMyMapCap(l int) *MyMap

func (*MyMap) AsImmutable

func (m *MyMap) AsImmutable(v *MyMap) *MyMap

func (*MyMap) AsMutable

func (m *MyMap) AsMutable() *MyMap

func (*MyMap) Del

func (m *MyMap) Del(k string) *MyMap

func (*MyMap) Get

func (m *MyMap) Get(k string) (*MySlice, bool)

func (*MyMap) IsDeeplyNonMutable

func (s *MyMap) IsDeeplyNonMutable(seen map[interface{}]bool) bool

func (*MyMap) Len

func (m *MyMap) Len() int

func (*MyMap) Mutable

func (m *MyMap) Mutable() bool

func (*MyMap) Range

func (m *MyMap) Range() map[string]*MySlice

func (*MyMap) Set

func (m *MyMap) Set(k string, v *MySlice) *MyMap

func (*MyMap) WithImmutable

func (mr *MyMap) WithImmutable(f func(m *MyMap)) *MyMap

func (*MyMap) WithMutable

func (mr *MyMap) WithMutable(f func(m *MyMap)) *MyMap

type MySlice

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

MySlice will be exported

MySlice is an immutable type and has the following template:

[]*MyMap

func NewMySlice

func NewMySlice(s ...*MyMap) *MySlice

func NewMySliceLen

func NewMySliceLen(l int) *MySlice

func (*MySlice) Append

func (m *MySlice) Append(v ...*MyMap) *MySlice

func (*MySlice) AsImmutable

func (m *MySlice) AsImmutable(v *MySlice) *MySlice

func (*MySlice) AsMutable

func (m *MySlice) AsMutable() *MySlice

func (*MySlice) Get

func (m *MySlice) Get(i int) *MyMap

func (*MySlice) IsDeeplyNonMutable

func (s *MySlice) IsDeeplyNonMutable(seen map[interface{}]bool) bool

func (*MySlice) Len

func (m *MySlice) Len() int

func (*MySlice) Mutable

func (m *MySlice) Mutable() bool

func (*MySlice) Range

func (m *MySlice) Range() []*MyMap

func (*MySlice) Set

func (m *MySlice) Set(i int, v *MyMap) *MySlice

func (*MySlice) WithImmutable

func (m *MySlice) WithImmutable(f func(mi *MySlice)) *MySlice

func (*MySlice) WithMutable

func (m *MySlice) WithMutable(f func(mi *MySlice)) *MySlice

type MyStruct

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

MyStruct will be exported.

It is a special type.

MyStruct is an immutable type and has the following template:

struct {
	Name	string

	surname	string

	self	*MyStruct

	age	int
}

func (*MyStruct) AsImmutable

func (s *MyStruct) AsImmutable(v *MyStruct) *MyStruct

func (*MyStruct) AsMutable

func (s *MyStruct) AsMutable() *MyStruct

func (*MyStruct) IsDeeplyNonMutable

func (s *MyStruct) IsDeeplyNonMutable(seen map[interface{}]bool) bool

func (*MyStruct) Mutable

func (s *MyStruct) Mutable() bool

func (*MyStruct) Name

func (s *MyStruct) Name() string

Name is a field in MyStruct

func (*MyStruct) SetName

func (s *MyStruct) SetName(n string) *MyStruct

SetName is the setter for Name()

func (*MyStruct) WithImmutable

func (s *MyStruct) WithImmutable(f func(si *MyStruct)) *MyStruct

func (*MyStruct) WithMutable

func (s *MyStruct) WithMutable(f func(si *MyStruct)) *MyStruct

type Person

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

via go generate, this template is code generated into the immutable Person struct within the same package

Person is an immutable type and has the following template:

struct {
	Name	string
	Age	int
}

func (*Person) Age

func (s *Person) Age() int

func (*Person) AsImmutable

func (s *Person) AsImmutable(v *Person) *Person

func (*Person) AsMutable

func (s *Person) AsMutable() *Person

func (*Person) IsDeeplyNonMutable

func (s *Person) IsDeeplyNonMutable(seen map[interface{}]bool) bool

func (*Person) Mutable

func (s *Person) Mutable() bool

func (*Person) Name

func (s *Person) Name() string

func (*Person) SetAge

func (s *Person) SetAge(n int) *Person

SetAge is the setter for Age()

func (*Person) SetName

func (s *Person) SetName(n string) *Person

SetName is the setter for Name()

func (*Person) String

func (p *Person) String() string

Hence we can then define methods on *Person (methods can only be defined on a pointer receiver)

func (*Person) WithImmutable

func (s *Person) WithImmutable(f func(si *Person)) *Person

func (*Person) WithMutable

func (s *Person) WithMutable(f func(si *Person)) *Person

Jump to

Keyboard shortcuts

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