Advertisement
arxeiss

TOML config loading

May 14th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.55 KB | None | 0 0
  1. // Config object
  2. type SpamlerConfig struct {
  3.     SecureURL       string // SecureURL to listen
  4.     NonSecureURL    string // Non secure URL to listen for redirection, can be ommited
  5.     SMTP            string // SMTP server
  6.     Port            int    // Port of SMTP server
  7.     SkipInsecureTLS bool   // Skip insecure TLS certificate on SMTP server
  8. }
  9.  
  10. // Load file
  11. file, err := ioutil.ReadFile(filePath)
  12. if err != nil {
  13.     log.Fatal(err)
  14. }
  15. // Parse file
  16. var configData SpamlerConfig
  17. if _, err := toml.Decode(string(file), &configData); err != nil {
  18.     log.Fatal(err)
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement