feat: 新增 modular 包,用于实现模块化项目

This commit is contained in:
kercylan98
2024-01-30 14:22:26 +08:00
parent 6b24b7c576
commit c95b206592
7 changed files with 184 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
package expose
type Attack interface {
Name() string
}

View File

@@ -0,0 +1,5 @@
package expose
type Login interface {
Name() string
}

View 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
}

View 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
}