A golang library that can be used to construct finite-state machines.
A finite-state machine is an abstract machine that can be in exactly one of a finite number of states at any given time.
The API and design of this library is inspired by the finite-state machine implementation in the golang template lexer.
To install go-fsm, use go get.
go get github.com/austingebauer/go-fsmThen import the library into your Go program.
import "github.com/austingebauer/go-fsm"See example usage in example/main.go, which uses go-fsm to write a finite-state machine for the pacman ghosts state machine.
To run the example:
go run example/main.goTo generate a state diagram showing the states, transitions, and steps of the finite-state machine execution:
dot example/dot_graph.gv -T png > example/dot_graph.png && open example/dot_graph.pngAn example image generated from running the example finite-state machine:
Pull requests are welcome.
For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests along with changes.
