default.go
package controllers import (
"beego-test/models"
"beego-test/service"
"github.com/astaxie/beego"
) type MainController struct {
beego.Controller
} func (c *MainController) Get() {
c.Data["Website"] = "beego.me"
c.Data["Email"] = "astaxie@gmail.com"
service.Print()
models.Mmodel()
new(service.Service2).Print2()
c.TplName = "index.tpl"
}
models.go
package models import (
"fmt"
) func init() {
fmt.Println("...initMmodel...")
} func Mmodel() {
fmt.Println("...PrintMmodel...")
}
service.go
package service import (
"fmt"
) func init() {
fmt.Println("...init...")
} func Print() {
fmt.Println("...Print...")
}
service1.go
package service import (
"fmt"
) func init() {
fmt.Println("...init1...")
} func Print1() {
fmt.Println("...Print1...")
}
service2.go
package service import (
"fmt"
) type Service2 struct {
} func (this *Service2) init() {
fmt.Println("...init.service2..")
} func (this *Service2) Print2() {
fmt.Println("...Print.service2..")
}