More changes to config, not working yet

This commit is contained in:
Matthieu Grieger 2014-12-13 09:47:42 -08:00
parent 0629776b81
commit bc4091f639
3 changed files with 9 additions and 16 deletions

View file

@ -59,6 +59,8 @@ func parseCommand(username, command string) {
if success {
fmt.Println("Kill successful!")
}
case "test":
fmt.Printf("Title: %s\n", dj.conf.title)
}
}

View file

@ -21,7 +21,7 @@ type mumbledj struct {
client *gumble.Client
keepAlive chan bool
defaultChannel string
conf config
conf djConfig
}
func (dj *mumbledj) OnConnect(e *gumble.ConnectEvent) {

View file

@ -9,12 +9,10 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"github.com/BurntSushi/toml"
)
type config struct {
type djConfig struct {
title string
general generalConfig
volume volumeConfig
@ -55,17 +53,10 @@ type permissionsConfig struct {
adminKill bool `toml:"admin_kill"`
}
func loadConfiguration() (config, error) {
file, err := ioutil.ReadFile("config.toml")
if err != nil {
panic(err)
} else {
fileString := string(file)
var conf config
if _, err := toml.Decode(fileString, &conf); err != nil {
return conf, errors.New("Configuration load failed.")
}
return conf, nil
func loadConfiguration() (djConfig, error) {
var conf djConfig
if _, err := toml.DecodeFile("config.toml", &conf); err != nil {
return conf, errors.New("Configuration load failed.")
}
return conf, nil
}