The fsm
module implements a minimal finite state machine.
I used this logic in multiple projects, so I decided I may as well publish it. Honestly, this module is so simple you might be better off just copying the logic instead of importing it.
See the Go reference link above.