refactor(login): 重构登录模块代码
- 移除未使用的 in.go 和 out.go 文件 - 优化 login.go 中的代码结构 - 添加新的 go.mod 依赖
This commit is contained in:
36
logic/service/fight/fsm_test.go
Normal file
36
logic/service/fight/fsm_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package fight
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/looplab/fsm"
|
||||
)
|
||||
|
||||
func Test_main(t *testing.T) {
|
||||
fsm := fsm.NewFSM(
|
||||
"closed",
|
||||
fsm.Events{
|
||||
{Name: "open", Src: []string{"closed"}, Dst: "open"},
|
||||
{Name: "close", Src: []string{"open"}, Dst: "closed"},
|
||||
},
|
||||
fsm.Callbacks{},
|
||||
)
|
||||
|
||||
fmt.Println(fsm.Current())
|
||||
|
||||
err := fsm.Event(context.Background(), "open")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Println(fsm.Current())
|
||||
|
||||
err = fsm.Event(context.Background(), "close")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Println(fsm.Current())
|
||||
}
|
||||
Reference in New Issue
Block a user