Tag Golang

A cool golang interface trick

While working on juju, I noticed a curious code snippet: var ( stepPrepare = executorStep{"preparing", Operation.Prepare} stepExecute = executorStep{"executing", Operation.Execute} stepCommit = executorStep{"committing", Operation.Commit} ) where Operation is an interface: type Operation interface { Prepare(state State) (*State, error) Execute(state State) (*State, error) Commit(state State) (*State, error) } Surely, storing a method of an interface definition as a variable makes no sense. But then again, what is the type of an interface method?