not proper enum compararison
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package enum
|
||||
|
||||
import "fmt"
|
||||
|
||||
type InfrastructureType int
|
||||
|
||||
const (
|
||||
@@ -18,3 +20,11 @@ func (t InfrastructureType) String() string {
|
||||
func InfrastructureList() []InfrastructureType {
|
||||
return []InfrastructureType{DOCKER, KUBERNETES, SLURM, HW, CONDOR}
|
||||
}
|
||||
|
||||
func (d InfrastructureType) Compare(indexStr interface{}) bool {
|
||||
return fmt.Sprintf("%v", indexStr) == fmt.Sprintf("%v", d.EnumIndex()) || fmt.Sprintf("%v", indexStr) == d.String()
|
||||
}
|
||||
|
||||
func (d InfrastructureType) EnumIndex() int {
|
||||
return int(d)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user