not proper enum compararison
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package enum
|
||||
|
||||
import "fmt"
|
||||
|
||||
type StorageSize int
|
||||
|
||||
// StorageType - Enum that defines the type of storage
|
||||
@@ -54,3 +56,11 @@ func (t StorageType) String() string {
|
||||
func TypeList() []StorageType {
|
||||
return []StorageType{FILE, STREAM, API, DATABASE, S3, MEMORY, HARDWARE, AZURE, GCS}
|
||||
}
|
||||
|
||||
func (d StorageType) Compare(indexStr interface{}) bool {
|
||||
return fmt.Sprintf("%v", indexStr) == fmt.Sprintf("%v", d.EnumIndex()) || fmt.Sprintf("%v", indexStr) == d.String()
|
||||
}
|
||||
|
||||
func (d StorageType) EnumIndex() int {
|
||||
return int(d)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user