I'm trying to read a toml file with Go. I want to have different filesystems not only filesystem.file but for example also filesystem.s3, which have different paths defined. But it only returns an empty struct {map[file:{map[]}]}. What am I missing?
I'm using this library for reading the toml file: https://github.com/BurntSushi/toml
toml file:
[filesystem.file]
[filesystem.file.test]
folder = "tmp/testdata"
[filesystem.file.test2]
folder = "tmp/testdata2"
[filesystem.s3]
[filesystem.s3.test]
folder = "s3folder/testdata"
My go code:
package main
type File struct {
Folder string `toml:"folder"`
}
type FileSystem struct {
File map[string]File `toml:"file"`
}
type Config struct {
FileSystem map[string]FileSystem `toml:"filesystem"`
}
func main() {
var conf Config
_, err := toml.DecodeFile("test.toml", &conf)
if err != nil {
log.Fatalln("Error on loading config: ", err)
}
log.Printf("config: %v", conf)
}