add configuration
This commit is contained in:
23
config/config.go
Normal file
23
config/config.go
Normal 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user