secret-santa/internal/config/config.go
2024-11-17 00:54:15 +01:00

29 lines
481 B
Go

package config
import "fmt"
type AppConfig struct {
ListenIP string `json:"listen_ip"`
ListenPort int `json:"listen_port"`
}
func (c *AppConfig) GenerateIP() string {
return fmt.Sprintf("%s:%d", c.ListenIP, c.ListenPort)
}
func NewAppConfig(port *int, ip *string) AppConfig {
defaultPort := 8080
defaultIp := "127.0.0.1"
if port == nil {
port = &defaultPort
}
if ip == nil {
ip = &defaultIp
}
return AppConfig{
ListenIP: *ip,
ListenPort: *port,
}
}