Created
May 1, 2023 20:22
-
-
Save bensonmacharia/329c8996826e91ff8368e87f9aafbf55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// load required packages | |
import ( | |
"bmacharia/jwt-go-rbac/database" | |
"fmt" | |
"log" | |
"github.com/gin-gonic/gin" | |
"github.com/joho/godotenv" | |
) | |
func main() { | |
// load environment file | |
loadEnv() | |
// load database configuration and connection | |
loadDatabase() | |
// start the server | |
serveApplication() | |
} | |
func loadEnv() { | |
err := godotenv.Load(".env") | |
if err != nil { | |
log.Fatal("Error loading .env file") | |
} | |
log.Println(".env file loaded successfully") | |
} | |
func loadDatabase() { | |
database.InitDb() | |
} | |
func serveApplication() { | |
router := gin.Default() | |
router.Run(":8000") | |
fmt.Println("Server running on port 8000") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment