/go-state-machine

State Machine implementation in Golang

Primary LanguageGoMIT LicenseMIT

StateMachine

State Machine implementation in Golang

Creating State with rules

var IdleState *State

IdleState = &State{
		Name: "idle",
		Handler: func(ev string) *State {
			switch ev {
			case InsertCardEvent:
				return ActiveState
			case ErrorEvent:
				return OutOfServiceState
			default:
				return nil
			}
		},
	}