0

I want to group my controllers in some folder structure.

Application works if controllers are directly in 'controllers' folder.

Once I move controller to some controllers sub folder, router is not loading controller at all. (there's not compile errors)

Can anyone help me with that ?

  • The Go tools only allow a 1 directory per package, and vice versa. Why do you need multiple directories? – JimB Mar 28 '16 at 12:50

1 Answers1

0

I suspect you don't have the initialization code for your other controller packages.

For example, if you have a UserController in an admin package, like admin.UserController, you should also have one init() func in that admin package, that looks something like:

func init() {
    beego.Router("/admin/user", &admin.UserController{})
    // any other controllers register here ...
}

Also, make sure to import the controller package in your main package, probably as an underscore import if there is nothing directly using it:

import (
    _ "github.com/foo/bar/controllers/admin"
)
John Weldon
  • 39,849
  • 11
  • 94
  • 127