first commit

This commit is contained in:
2023-04-15 16:23:34 +07:00
commit bbed7f94f4
20 changed files with 533 additions and 0 deletions

38
config/config.go Normal file
View File

@ -0,0 +1,38 @@
package config
import (
"log"
"os"
"github.com/joho/godotenv"
)
var DownloadFolder string
var HTTPPort string
var DBName string
var TMDbApiKey string
func Load() {
if err := godotenv.Load(); err != nil {
log.Println("Error loading .env file ...")
log.Println("Using default configuration")
}
if DownloadFolder = os.Getenv("DOWNLOAD_FOLDER"); DownloadFolder == "" {
DownloadFolder = "/home/rouggy/torrents/rtorrent/Race"
}
if HTTPPort = os.Getenv("HTTP_PORT"); HTTPPort == "" {
HTTPPort = "9000"
}
if DBName = os.Getenv("DB_NAME"); DBName == "" {
DBName = "racerdb"
}
if TMDbApiKey = os.Getenv("TMDB_APIKEY"); TMDbApiKey == "" {
log.Println("TMDb Api Key cannot be empty...")
os.Exit(1)
}
}