These steps cover writing and running your application:
- From your terminal/console application, create the chapter10/consensus directory and navigate to it.
- Copy tests from https://github.com/agtorre/go-cookbook/tree/master/chapter10/consensus, or use this as an exercise to write some of your own code.
- Create a file called state.go with the following content:
package consensus type state string const ( first state = "first" second = "second" third = "third" ) var allowedState map[state][]state func init() { // setup valid states allowedState = make(map[state][]state) allowedState[first] = []state{second, third} allowedState[second] = []state{third} allowedState[third] = []state{first} } // CanTransition checks if a ...