types

package module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 6 Imported by: 0

README

extend-types-go

This package supports your object-oriented programming. extend-types-go provides extended objects inheriting from built-in types and a list of extended slices.

Extended objects are immutable objects, and implemented methods are non-destructive. They implement typecast methods and several utility methods, reducing the need to define your own value objects of the underlying type.

list is a defined type of slice that uses generics and implements a set of methods based on Ruby Array.

Contributing

This was originally an implementation for myself, but I am currently in the process of experimentally releasing it as OSS. I am a beginner in OSS development, and there may be various insufficient elements. So contributions are most welcome.

Reporting Issues

Please report issues using the Issues tab at the top of this page.

Pull Requests

If you modify the code please submit a pull request for review.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool bool

func NewBool

func NewBool[T ~bool](b T) Bool

func (Bool) And

func (b Bool) And(v bool) bool

func (Bool) CoreTypeName

func (b Bool) CoreTypeName() string

func (Bool) Not

func (b Bool) Not(v bool) bool

func (Bool) Or

func (b Bool) Or(v bool) bool

func (Bool) Print

func (b Bool) Print(label string)

Print with label. if label="example" then output: example: ${b}

func (Bool) Ptr

func (b Bool) Ptr() *bool

func (Bool) String

func (b Bool) String() string

func (Bool) Validate

func (b Bool) Validate() error

func (Bool) XOr

func (b Bool) XOr(v bool) bool

type Char

type Char struct {
	// contains filtered or unexported fields
}
Example (Char)
c := NewChar("a")
fmt.Printf("c: %v\n", c)
Output:

c: a
Example (String)
c := NewChar("hoge")
fmt.Printf("c: %v\n", c)
Output:

c: h

func NewChar

func NewChar[T ~string](char T) Char

func (Char) Byte

func (c Char) Byte() byte

func (Char) CoreTypeName

func (b Char) CoreTypeName() string

func (Char) DeepEqual

func (b Char) DeepEqual(v T) bool

func (Char) Equal

func (b Char) Equal(v T) bool

func (Char) Print

func (b Char) Print(label string)

Print with label. if label="example" then output: example: ${b.v}

func (Char) Ptr

func (b Char) Ptr() *T

func (Char) String

func (c Char) String() string

func (Char) Validate

func (b Char) Validate() error

func (Char) Value added in v0.2.2

func (b Char) Value() T

type Comparator

type Comparator[T comparable] interface {
	Equal(T) bool
	DeepEqual(T) bool
}

type Enumerator

type Enumerator[T any, I comparable, R any] interface {
	Find(func(T) bool) (T, bool)
	Filter(func(T, I) bool) R
	Each(func(T))
	EachWithIndex(func(T, I))
	Reject(func(T, I) bool) R
	Count(func(T) bool) int
}

type Float

type Float[T constraints.Float] struct {
	// contains filtered or unexported fields
}
Example
f := NewFloat(5.5)
fmt.Printf("f: %v\n", f)
Output:

f: 5.5

func NewFloat

func NewFloat[T constraints.Float](v T) Float[T]

func (Float[T]) Abs

func (f Float[T]) Abs() T

func (Float[T]) Ceil

func (f Float[T]) Ceil() T

func (Float) CoreTypeName

func (b Float) CoreTypeName() string

func (Float) DeepEqual

func (b Float) DeepEqual(v T) bool

func (Float) Equal

func (b Float) Equal(v T) bool

func (Float[T]) Float32

func (f Float[T]) Float32() float32

func (Float[T]) Float64

func (f Float[T]) Float64() float64

func (Float[T]) Floor

func (f Float[T]) Floor() T

func (Float[T]) Int

func (f Float[T]) Int() int

func (Float[T]) Int16

func (f Float[T]) Int16() int16

func (Float[T]) Int32

func (f Float[T]) Int32() int32

func (Float[T]) Int64

func (f Float[T]) Int64() int64

func (Float[T]) Int8

func (f Float[T]) Int8() int8

func (Float[T]) IsNegative

func (f Float[T]) IsNegative() bool

func (Float[T]) IsPositive

func (f Float[T]) IsPositive() bool

func (Float[T]) IsZero

func (f Float[T]) IsZero() bool

func (Float) Print

func (b Float) Print(label string)

Print with label. if label="example" then output: example: ${b.v}

func (Float) Ptr

func (b Float) Ptr() *T

func (Float[T]) Round

func (f Float[T]) Round() T

func (Float[T]) Str

func (f Float[T]) Str() Str

func (Float) String

func (b Float) String() string

func (Float[T]) UInt16

func (f Float[T]) UInt16() uint16

func (Float[T]) UInt32

func (f Float[T]) UInt32() uint32

func (Float[T]) UInt64

func (f Float[T]) UInt64() uint64

func (Float[T]) UInt8

func (f Float[T]) UInt8() uint8

func (Float) Validate

func (b Float) Validate() error

func (Float) Value added in v0.2.2

func (b Float) Value() T

type Integer

type Integer[T constraints.Integer] struct {
	// contains filtered or unexported fields
}

func NewInteger

func NewInteger[T constraints.Integer](i T) Integer[T]

func (Integer) CoreTypeName

func (b Integer) CoreTypeName() string

func (Integer) DeepEqual

func (b Integer) DeepEqual(v T) bool

func (Integer) Equal

func (b Integer) Equal(v T) bool

func (Integer[T]) Float

func (i Integer[T]) Float() Float[float64]

func (Integer[T]) Int

func (i Integer[T]) Int() int

func (Integer[T]) Int16

func (i Integer[T]) Int16() int16

func (Integer[T]) Int32

func (i Integer[T]) Int32() int32

func (Integer[T]) Int64

func (i Integer[T]) Int64() int64

func (Integer[T]) Int8

func (i Integer[T]) Int8() int8

func (Integer[T]) IsNegative

func (i Integer[T]) IsNegative() bool

func (Integer[T]) IsPositive

func (i Integer[T]) IsPositive() bool

func (Integer[T]) IsZero

func (i Integer[T]) IsZero() bool

func (Integer) Print

func (b Integer) Print(label string)

Print with label. if label="example" then output: example: ${b.v}

func (Integer) Ptr

func (b Integer) Ptr() *T

func (Integer[T]) Str

func (i Integer[T]) Str() Str

func (Integer) String

func (b Integer) String() string

func (Integer[T]) UInt16

func (i Integer[T]) UInt16() uint16

func (Integer[T]) UInt32

func (i Integer[T]) UInt32() uint32

func (Integer[T]) UInt64

func (i Integer[T]) UInt64() uint64

func (Integer[T]) UInt8

func (i Integer[T]) UInt8() uint8

func (Integer) Validate

func (b Integer) Validate() error

func (Integer) Value added in v0.2.2

func (b Integer) Value() T

type Str

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

func NewStr

func NewStr[T ~string](s T) Str

func NewStrFromBytes

func NewStrFromBytes(data []byte) Str

func (Str) Bytes

func (s Str) Bytes() []byte

func (Str) CoreTypeName

func (b Str) CoreTypeName() string

func (Str) DeepEqual

func (b Str) DeepEqual(v T) bool

func (Str) Equal

func (b Str) Equal(v T) bool

func (Str) Include

func (s Str) Include(sub string) bool

func (Str) Print

func (b Str) Print(label string)

Print with label. if label="example" then output: example: ${b.v}

func (Str) Ptr

func (b Str) Ptr() *T

func (Str) Size

func (s Str) Size() int

func (Str) Split

func (s Str) Split(sep string) []Str

func (Str) String

func (b Str) String() string

func (Str) Validate

func (b Str) Validate() error

func (Str) Value added in v0.2.2

func (b Str) Value() T

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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