Files
any2anexoj/internal/kind.go
T
natercioandnatercio 9bd4230ff1
Badges / coveralls (push) Successful in 1m4s
Internal state persistence (#27)
Allow us to generate year over year reports without having to rerun everything from the beginning.

Co-authored-by: Natercio Moniz <[email protected]>
2026-08-03 00:33:06 +01:00

37 lines
619 B
Go

package internal
type Kind uint
const (
KindUnknown Kind = iota
KindBuy
KindSell
KindSplit
sentinelKind
)
// String returns a unique string value for Kind k
func (k Kind) String() string {
switch k {
case KindBuy:
return "buy"
case KindSell:
return "sell"
case KindSplit:
return "split"
default:
return "unknown"
}
}
// Valid returns true if k is an accepted value for the Kind type
func (k Kind) Valid() bool {
return k > 0 && k < sentinelKind
}
// Is returns true when k and o are valid and equal.
func (k Kind) Is(o any) bool {
other, ok := o.(Kind)
return ok && k.Valid() && k == other
}