src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

config.go (440B)


      1 package config
      2 
      3 import (
      4 	_ "embed"
      5 	"encoding/json"
      6 	"fmt"
      7 
      8 	"code.dwrz.net/src/pkg/server"
      9 )
     10 
     11 //go:embed config.json
     12 var configuration []byte
     13 
     14 type Config struct {
     15 	Debug  bool           `json:"debug"`
     16 	Server *server.Config `json:"server"`
     17 }
     18 
     19 func New() (*Config, error) {
     20 	var cfg = &Config{}
     21 	if err := json.Unmarshal(configuration, cfg); err != nil {
     22 		return nil, fmt.Errorf("failed to parse config: %v", err)
     23 	}
     24 
     25 	return cfg, nil
     26 }