Skip to content

Instantly share code, notes, and snippets.

@hirokazumiyaji
Last active August 29, 2015 14:06
Show Gist options
  • Save hirokazumiyaji/a366d6f4da6fdf1d4c4a to your computer and use it in GitHub Desktop.
Save hirokazumiyaji/a366d6f4da6fdf1d4c4a to your computer and use it in GitHub Desktop.
go configuration
package go
import (
"io/ioutil"
"github.com/gonuts/yaml"
)
var Config = make(map[string]interface{})
func Load(yamlFile string) (err error) {
if yamlFile == "" {
yamlFile = "config.yaml"
}
buffer, err := ioutil.ReadFile(yamlFile)
if err != nil {
return err
}
err = yaml.Unmarshal(buffer, &Config)
if err != nil {
return err
}
return err
}
databases:
default:
dbname: 'default'
host: 'localhost'
port: 3393
username: 'root'
password: ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment