From 4290c83957205ef707fe889d7a5a6e25a3c592eb Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 23 Apr 2019 09:04:13 -0700 Subject: [PATCH] Update the state to have a different type --- behavioral/state/state.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/behavioral/state/state.go b/behavioral/state/state.go index 578a716..56fd79b 100644 --- a/behavioral/state/state.go +++ b/behavioral/state/state.go @@ -40,16 +40,17 @@ func (s *StopState) executeState(c *Context) { func StateDemo() { context := &Context{} + var state State - startState := &StartState{} - startState.executeState(context) + state = &StartState{} + state.executeState(context) fmt.Println("state: ", context) - inprState := &InprogressState{} - inprState.executeState(context) + state = &InprogressState{} + state.executeState(context) fmt.Println("state: ", context) - stopState := &StopState{} - stopState.executeState(context) + state = &StopState{} + state.executeState(context) fmt.Println("state: ", context) }