FSM - Finite state machine in Go
Go
Latest commit aa81493 Dec 23, 2016 @yandd fix readme.md
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
fsm.go
fsm.png
fsm_test.go
readme.md

readme.md

FSM - Finite state machine in Go

usage

go get github.com/yandd/fsm

example

fsm

f, err := fsm.NewFSM("inited", []interface{}{"ended"}, fsm.FSMEvents{
    {Name: "start", From: "inited", To: "started"},
    {Name: "work", From: "started", To: "working"},
    {Name: "end", From: []interface{}{"started", "working"}, To: "ended"},
})

support export .dot file

f.Dot("diag_name")
digraph diag_name {
    rankdir=LR;
    node [shape = doublecircle];ended ;
    node [shape = circle];

    inited -> started [ label = "start" ];
    started -> working [ label = "work" ];
    started -> ended [ label = "end" ];
    working -> ended [ label = "end" ];
}