Allow us to generate year over year reports without having to rerun everything from the beginning. Co-authored-by: Natercio Moniz <[email protected]>
This commit was merged in pull request #27.
This commit is contained in:
+11
-5
@@ -7,11 +7,12 @@ const (
|
||||
KindBuy
|
||||
KindSell
|
||||
KindSplit
|
||||
sentinelKind
|
||||
)
|
||||
|
||||
// String returns a human readable value
|
||||
func (d Kind) String() string {
|
||||
switch d {
|
||||
// String returns a unique string value for Kind k
|
||||
func (k Kind) String() string {
|
||||
switch k {
|
||||
case KindBuy:
|
||||
return "buy"
|
||||
case KindSell:
|
||||
@@ -23,8 +24,13 @@ func (d Kind) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// Is returns true when k equals o
|
||||
// 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 == other
|
||||
return ok && k.Valid() && k == other
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user