--|--child_package1
--|--child_package2
--|--child_packege3
I have all the the routes and method call for API hit listed in main_package
router Handle from main_package.go
func Handlers(db *sql.DB, customeruploadFile string) *mux.Router {
router := mux.NewRouter()
router.HandleFunc("/api1", child_package1.method )
router.HandleFunc("/api2", child_package2.method)
router.HandleFunc("/api3", child_package3 .mehtod)
fileHandler := http.FileServer(http.Dir("./client/compiled"))
router.PathPrefix("/").Handler(http.StripPrefix("/", fileHandler))
return router
}
now the problem is when I write test cases for child packegs, I need this Handlers method to create test server, for that I need to import main_package in child_packages, then as obvious there is cycle imports happening, as child_packages are imported in main_pakcage.
Can any one please suggest me the best approach to tackle this.
Thanks