gocalc

package module
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 3 Imported by: 0

README

gocalc

Belajar membuat golang module dan unit test.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chainable

type Chainable[T Number] struct {
	// contains filtered or unexported fields
}

func (*Chainable[T]) Divide

func (c *Chainable[T]) Divide(n T) IChainable[T]

Divide performs division operation.

func (Chainable[T]) Error added in v2.1.0

func (c Chainable[T]) Error() error

func (Chainable[T]) IsError added in v2.1.0

func (c Chainable[T]) IsError() bool

func (Chainable[T]) LastErrorOperation added in v2.1.0

func (c Chainable[T]) LastErrorOperation() Operation

func (Chainable[T]) LastOperation added in v2.1.0

func (c Chainable[T]) LastOperation() Operation

func (Chainable[T]) LastSuccessOperation added in v2.1.0

func (c Chainable[T]) LastSuccessOperation() Operation

func (*Chainable[T]) Minus added in v2.2.0

func (c *Chainable[T]) Minus(n T) IChainable[T]

Minus performs substraction operation.

func (*Chainable[T]) Multiply

func (c *Chainable[T]) Multiply(n T) IChainable[T]

Multiply performs multiplication operation.

func (*Chainable[T]) Plus

func (c *Chainable[T]) Plus(n T) IChainable[T]

Plus performs addition operation.

func (Chainable[T]) Result added in v2.1.0

func (c Chainable[T]) Result() T

func (Chainable[T]) ResultAndError added in v2.1.0

func (c Chainable[T]) ResultAndError() (T, error)

type IChainable

type IChainable[T Number] interface {
	IChainableOperation[T]
	Result() T
	Error() error
	IsError() bool
	ResultAndError() (T, error)
	LastSuccessOperation() Operation
	LastErrorOperation() Operation
	LastOperation() Operation
}

func New

func New[T Number](value T) IChainable[T]

type IChainableOperation

type IChainableOperation[T Number] interface {
	Plus(T) IChainable[T]
	Minus(T) IChainable[T]
	Multiply(T) IChainable[T]
	Divide(T) IChainable[T]
}

type Number added in v2.2.0

type Number interface {
	constraints.Integer | constraints.Float
}

type Operation added in v2.1.0

type Operation int
const (
	Nop Operation = iota
	Plus
	Minus
	Multiply
	Divide
)

func (Operation) String added in v2.2.0

func (op Operation) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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