add config
This commit is contained in:
31
config/config.go
Normal file
31
config/config.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type ServerConfig struct {
|
||||
Port string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Server ServerConfig
|
||||
}
|
||||
|
||||
func New() *Config {
|
||||
return &Config{
|
||||
Server: ServerConfig{
|
||||
Port: getEnv("PORT", ""),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func getEnv(key string, defaultVal string) string {
|
||||
if value, exists := os.LookupEnv(key); exists {
|
||||
return value
|
||||
}
|
||||
|
||||
return defaultVal
|
||||
}
|
||||
|
||||
var Env = New()
|
||||
Reference in New Issue
Block a user