自定义组件
App (root)
├─ main.go
├─ app.yml
└─ components
└─ my
└─ my.go
package my
type Instance struct {
Message string `yaml:"message"`
}
const name = "my"
var instance *Instance
func (i *Instance) Run() error {
instance = i
return nil
}
func (i *Instance) GetName() string {
return name
}
func Get() *Instance {
return instance
}
my:
message: my name is langgo
package main
import (
"fmt"
"github.com/langwan/langgo"
"langwan/langgo-examples/Advanced/Custom-Components/components/my"
)
func main() {
langgo.Run(&my.Instance{})
fmt.Println(my.Get().Message)
}
Last updated