add configuration

This commit is contained in:
Pijus Kamandulis
2025-05-27 21:56:19 +03:00
parent d836830f45
commit 1cc12afa16
6 changed files with 79 additions and 24 deletions

23
config/config.go Normal file
View File

@@ -0,0 +1,23 @@
package config
import "flag"
type Config struct {
Port int `json:"port"`
LogPath string `json:"logPath"`
DatabasePath string `json:"databasePath"`
}
func ParseFlags() Config {
port := flag.Int("Port", 8080, "Listen port")
logPath := flag.String("LogPath", "logs", "Path to log files")
databasePath := flag.String("DatabasePath", "badgerdb", "Path to the database directory")
flag.Parse()
return Config{
Port: *port,
LogPath: *logPath,
DatabasePath: *databasePath,
}
}