The current approach of fsm is to use string to represent stages:
|
fsm := fsm.NewFSM( |
|
"closed", |
|
fsm.Events{ |
|
{Name: "open", Src: []string{"closed"}, Dst: "open"}, |
|
{Name: "close", Src: []string{"open"}, Dst: "closed"}, |
|
}, |
which is kind of error prone. These strings should better be replace with enum values instead, to
- save space, and most importantly
- allow compiler to do spellcheck for us
Like this:
type myFSM int
const (
Init myFSM = iota
Open
Progress
Close = Stop
)
For further details, check out https://pkg.go.dev/golang.org/x/tools/cmd/stringer
Please consider.
The current approach of fsm is to use string to represent stages:
fsm/examples/simple.go
Lines 14 to 19 in e668a85
which is kind of error prone. These strings should better be replace with enum values instead, to
Like this:
For further details, check out https://pkg.go.dev/golang.org/x/tools/cmd/stringer
Please consider.