config.json
{
"admins": [
"AdminA",
"AdminB"
],
"apikey": "apikey"
}
main.go
package main
import (
"os"
"fmt"
"encoding/json"
)
type MainConfiguration struct {
admins []string `json:"admins"`
apikey string `json:"apikey"`
}
func ParseConf() *MainConfiguration {
f, _ := os.Open("config.json")
defer f.Close()
d := json.NewDecoder(f)
m := &MainConfiguration{}
d.Decode(m)
return m
}
func main() {
conf := ParseConf()
fmt.Printf("%s", conf)
}
After looking for everything I could to fix this all I get is:
&{[] }
Whats wrong here, and why is this empty? Its basic and I've basically just copy/pasted from elsewhere and while this may be common, I'm not finding answers to this specific question.