business

package
v0.0.0-...-9052e1e Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cost

func Cost[T Number](usage, netto T) T

func PrintGeneric

func PrintGeneric[T any](t T) string

PrintGeneric returns any type as string. The string is enriched with the required Kineteco legal information.

func PrintSlice

func PrintSlice[T Energy](t []T)

PrintSlice prints all Energy items in t to stdout, note the generic is

using T Energy rather than any for a more specific or
constrained generic

func PrintSlice2

func PrintSlice2[T Energy, S ~[]T](t S)

PrintSlice2 uses a second constraint to replace []T as a slice of all items

that could be T (the ~ operator).
What this means is if we had say type myString string and string then
the constraint ~string would also match myString because it approximates
string

Types

type Complex

type Complex interface {
	~complex64 | ~complex128
}

Complex is another type-set interface but the use of ~ allows automatic extensibility,

should additional complex types be added to Go in the future

type Energy

type Energy interface {
	Solar | Wind // type-set which allows either Solar or Wind to be used in generics
	Cost() float64
}

type Number

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

type Solar

type Solar struct {
	Name  string
	Netto float64
}

Solar handles all the different energy offers powered by solar.

func (Solar) Cost

func (s Solar) Cost() float64

func (*Solar) Print

func (s *Solar) Print() string

Print prints the information for a solar product. The string is enriched with the required kineteco legal information.

type Wind

type Wind struct {
	Name  string
	Netto float64
}

Wind handles all the different energy offers powered by wind.

func (Wind) Cost

func (w Wind) Cost() float64

func (*Wind) Print

func (w *Wind) Print() string

Print prints the information for a wind product. The string is enriched with the required kineteco legal information.

Jump to

Keyboard shortcuts

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