Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

read_config.go 490B

1234567891011121314151617181920212223242526
  1. package utils
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/9seconds/mtg/v2/internal/config"
  6. )
  7. func ReadConfig(path string) (*config.Config, error) {
  8. content, err := os.ReadFile(path)
  9. if err != nil {
  10. return nil, fmt.Errorf("cannot read config file: %w", err)
  11. }
  12. conf, err := config.Parse(content)
  13. if err != nil {
  14. return nil, fmt.Errorf("cannot parse config: %w", err)
  15. }
  16. if err := conf.Validate(); err != nil {
  17. return nil, fmt.Errorf("invalid config: %w", err)
  18. }
  19. return conf, nil
  20. }