package config import ( "encoding/json" "os" ) type Config struct { DB DatabaseConfig Matrix MatrixConfig Server ServerConfig } type DatabaseConfig struct { Filename string } type MatrixConfig struct { AllowedRooms []string `json:"allowed_rooms"` DeviceName string `json:"device_name"` Greeting string LogLevel uint `json:"log_level"` HomeserverURL string `json:"homeserver_url"` UserIdentifier string `json:"user_identifier"` Password string PickleKey string `json:"pickle_key"` } type ServerConfig struct { APIToken string `json:"api_token"` BaseURL string `json:"base_url"` ListenAddress string `json:"listen_address"` } func ParseFromFile(path string) (*Config, error) { data, err := os.ReadFile(path) if err != nil { return nil, err } config := &Config{} err = json.Unmarshal(data, config) if err != nil { return nil, err } return config, nil }