Skip to content

Commit

Permalink
feat: Allow passing db as environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Dec 6, 2023
1 parent b1d21d2 commit 0cb489f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,16 @@ func setupRouter(dbPath string) (*gin.Engine, error) {
}

func main() {
router, err := setupRouter(os.Args[1])
var dbPath string
if len(os.Args) > 1 {
dbPath = os.Args[1]
} else if dbPathArg, ok := os.LookupEnv("db_path"); ok {
dbPath = dbPathArg
} else {
panic("No path to DB was provided. You must either pass it as a positional argument or by setting the 'db_path' environment variable")
}

router, err := setupRouter(dbPath)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 0cb489f

Please sign in to comment.