diff options
author | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-26 13:12:37 +0100 |
---|---|---|
committer | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-26 13:12:37 +0100 |
commit | 267c89fe42050d056b8c041ee66008e304c0bcf3 (patch) | |
tree | db3d519226bc8c58e3bd47196c6ae1fc25e0ca84 /config.go | |
parent | e13c16a261b71b7e590dda6c9ef826385b7b5b02 (diff) |
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 35 |
1 files changed, 15 insertions, 20 deletions
@@ -1,5 +1,10 @@ package main +import ( + "encoding/json" + "io/ioutil" +) + type Config struct { Database Database Storage Storage @@ -30,24 +35,14 @@ type API struct { Files string } -var config = Config{ - Database{ - Username: "audiocache", - Password: "audiocache", - Hostname: "localhost", - Database: "audiocache", - Adapter: "postgres", - SSLMode: "disable", - }, - Storage{ - Location: "/tmp/audiocache/", - }, - Server{ - Listen: "127.0.0.1", - Port: "8080", - }, - API{ - Location: "http://localhost:8080/", - Files: "files/", - }, +func LoadFile(filename string) (Config, error) { + var config Config + + file, err := ioutil.ReadFile(filename) + if err != nil { + return config, err + } + + err = json.Unmarshal(file, &config) + return config, err } |