feat: 新增 modular 包,用于实现模块化项目
This commit is contained in:
5
modular/example/internal/service/expose/attack.go
Normal file
5
modular/example/internal/service/expose/attack.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package expose
|
||||
|
||||
type Attack interface {
|
||||
Name() string
|
||||
}
|
||||
5
modular/example/internal/service/expose/login.go
Normal file
5
modular/example/internal/service/expose/login.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package expose
|
||||
|
||||
type Login interface {
|
||||
Name() string
|
||||
}
|
||||
27
modular/example/internal/service/services/attack/attack.go
Normal file
27
modular/example/internal/service/services/attack/attack.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package attack
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/kercylan98/minotaur/modular/example/internal/service/expose"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
Login expose.Login
|
||||
name string
|
||||
}
|
||||
|
||||
func (a *Service) OnInit() {
|
||||
a.name = "attack"
|
||||
}
|
||||
|
||||
func (a *Service) OnPreload() {
|
||||
fmt.Println(a.name, "call", a.Login.Name())
|
||||
}
|
||||
|
||||
func (a *Service) OnMount() {
|
||||
|
||||
}
|
||||
|
||||
func (a *Service) Name() string {
|
||||
return a.name
|
||||
}
|
||||
27
modular/example/internal/service/services/login/login.go
Normal file
27
modular/example/internal/service/services/login/login.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package login
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/kercylan98/minotaur/modular/example/internal/service/expose"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
Attack expose.Attack
|
||||
name string
|
||||
}
|
||||
|
||||
func (l *Service) OnInit() {
|
||||
l.name = "login"
|
||||
}
|
||||
|
||||
func (l *Service) OnPreload() {
|
||||
fmt.Println(l.name, "call", l.Attack.Name())
|
||||
}
|
||||
|
||||
func (l *Service) OnMount() {
|
||||
|
||||
}
|
||||
|
||||
func (l *Service) Name() string {
|
||||
return l.name
|
||||
}
|
||||
Reference in New Issue
Block a user