A state machine by golang