summaryrefslogtreecommitdiff
path: root/internal/fsm
diff options
context:
space:
mode:
authorJeroen Wijenbergh <jeroen.wijenbergh@geant.org>2025-05-06 12:40:47 +0200
committerJeroen Wijenbergh <jeroen.wijenbergh@geant.org>2025-05-06 12:40:47 +0200
commit347b20fc91505584bc9efbeca89590a411b95e79 (patch)
tree9dfc600e957c4a881115f8bc8a9cc107a4f0cc9c /internal/fsm
parent9c4985368aee638d982f30ea7bc5c7ee71ae3ab3 (diff)
All: Run modernize --test --fix
Diffstat (limited to 'internal/fsm')
-rw-r--r--internal/fsm/fsm.go8
-rw-r--r--internal/fsm/fsm_test.go8
2 files changed, 8 insertions, 8 deletions
diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go
index 5985aa5..c3b9255 100644
--- a/internal/fsm/fsm.go
+++ b/internal/fsm/fsm.go
@@ -54,7 +54,7 @@ type FSM struct {
// StateCallback is the function ran when a transition occurs
// It takes the old state, the new state and the data and returns if this is handled by the client
- StateCallback func(StateID, StateID, interface{}) bool
+ StateCallback func(StateID, StateID, any) bool
// GetStateName gets the name of a state as a string
GetStateName func(StateID) string
@@ -64,7 +64,7 @@ type FSM struct {
}
// NewFSM creates a new finite state machine
-func NewFSM(current StateID, states States, callback func(StateID, StateID, interface{}) bool, nameGen func(StateID) string) FSM {
+func NewFSM(current StateID, states States, callback func(StateID, StateID, any) bool, nameGen func(StateID) string) FSM {
return FSM{
States: states,
Current: current,
@@ -97,7 +97,7 @@ func (fsm *FSM) CheckTransition(desired StateID) error {
// GoTransitionRequired transitions the state machine to a new state with associated state data 'data'
// If this transition is not handled by the client, it returns an error.
-func (fsm *FSM) GoTransitionRequired(newState StateID, data interface{}) error {
+func (fsm *FSM) GoTransitionRequired(newState StateID, data any) error {
oldState := fsm.Current
handled, err := fsm.GoTransitionWithData(newState, data)
@@ -114,7 +114,7 @@ func (fsm *FSM) GoTransitionRequired(newState StateID, data interface{}) error {
// GoTransitionWithData is a helper that transitions the state machine toward the 'newState' with associated state data 'data'
// It returns whether or not the transition is handled by the client.
-func (fsm *FSM) GoTransitionWithData(newState StateID, data interface{}) (bool, error) {
+func (fsm *FSM) GoTransitionWithData(newState StateID, data any) (bool, error) {
if err := fsm.CheckTransition(newState); err != nil {
return false, err
}
diff --git a/internal/fsm/fsm_test.go b/internal/fsm/fsm_test.go
index c160477..dc8ddc8 100644
--- a/internal/fsm/fsm_test.go
+++ b/internal/fsm/fsm_test.go
@@ -57,7 +57,7 @@ func testFSM() FSM {
Transitions: []Transition{},
},
}
- cb := func(StateID, StateID, interface{}) bool {
+ cb := func(StateID, StateID, any) bool {
return false
}
namecb := func(in StateID) string {
@@ -149,7 +149,7 @@ func TestGoTransitionRequired(t *testing.T) {
for _, c := range cases {
curr := machine.Current
- machine.StateCallback = func(_ StateID, newState StateID, data interface{}) bool {
+ machine.StateCallback = func(_ StateID, newState StateID, data any) bool {
if c.WantErr == "" && newState != c.In {
t.Fatalf("new state is not what we want, got: %v, want: %v", newState, c.In)
}
@@ -214,10 +214,10 @@ func TestGoTransition(t *testing.T) {
for _, c := range cases {
curr := machine.Current
- machine.StateCallback = func(StateID, StateID, interface{}) bool {
+ machine.StateCallback = func(StateID, StateID, any) bool {
return c.Handle
}
- machine.StateCallback = func(_ StateID, newState StateID, data interface{}) bool {
+ machine.StateCallback = func(_ StateID, newState StateID, data any) bool {
if c.WantErr == "" && newState != c.In {
t.Fatalf("new state is not what we want, got: %v, want: %v", newState, c.In)
}