I have a main.go file that has:
func main() {
router,Global := routers.InitApp()
fmt.println(Global)
router.RunTLS(":9000" , "domain.crt" , "domain.key")
}
In router.InitMapI want to declare a global variable that can be accessed anywhere in my application. Is it possible? I have tried:
func InitApp() (*gin.Engine,string) {
var Global= "myvalue"
router := gin.New()
return router,Global
}
But I can’t access the variable Globaleven in the same package.
source
share