package config import ( "encoding/json" "fmt" "os" ) type NetboxConfig struct { BaseURL string `json:"baseURL"` APIKey string `json:"apiKey"` } type MikrotikConfig struct { IPAddress string `json:"ipAddress"` User string `json:"user"` Password string `json:"password"` } type AppConfig struct { Netbox NetboxConfig `json:"netbox"` Mikrotik []MikrotikConfig `json:"mikrotik"` } func New(configPath string) (*AppConfig, error) { content, err := os.ReadFile(configPath) if err != nil { return nil, fmt.Errorf("failed to read config: %w", err) } var conf AppConfig if err := json.Unmarshal(content, &conf); err != nil { return nil, fmt.Errorf("invalid config content: %w", err) } return &conf, nil }