diff --git a/backend/file/file.go b/backend/file/file.go index 1feff25..44226fe 100644 --- a/backend/file/file.go +++ b/backend/file/file.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" + "github.com/BurntSushi/toml" "github.com/go-yaml/yaml" "github.com/pkg/errors" ) @@ -47,6 +48,8 @@ func (b *Backend) Unmarshal(ctx context.Context, to interface{}) error { fallthrough case ".yaml": err = yaml.NewDecoder(f).Decode(to) + case ".toml": + _, err = toml.DecodeReader(f, to) default: err = errors.Errorf("unsupported extension \"%s\"", ext) } diff --git a/backend/file/file_test.go b/backend/file/file_test.go index 6d77f8f..dcced62 100644 --- a/backend/file/file_test.go +++ b/backend/file/file_test.go @@ -72,6 +72,17 @@ func TestFileBackend(t *testing.T) { testLoad(t, path) }) + t.Run("TOML", func(t *testing.T) { + path, cleanup := createTempFile(t, "config.toml", + `name = "some name" +age = 10 +timeout = 10 +`) + defer cleanup() + + testLoad(t, path) + }) + t.Run("Unsupported extension", func(t *testing.T) { path, cleanup := createTempFile(t, "config.xml", `{ "name": "some name"