knadh / koanf

Simple, extremely lightweight, extensible, configuration management library for Go. Support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TOML is Broken since Pellitier upgraded to v2 of go-toml

codevyper opened this issue · comments

Describe the bug
Compilation of toml.go in Koanf fails because pelletier/go-toml no longer has the LoadReader or TreeFromMap funcs in the library

To Reproduce
go get clean install of koanf and create a job that requires parsing a TOML file. It will generate two errors from the toml.go file in Koanf:

src/github.com/knadh/koanf/parsers/toml/toml.go:20:17: undefined: toml.LoadReader
src/github.com/knadh/koanf/parsers/toml/toml.go:29:19: undefined: toml.TreeFromMap

Expected behavior
Read and parse a TOML config file

Please provide the following information):
OSX Monterey
Koanf v1.5.0

Additional context
Grepped the source for pelletier/go-toml v2.0.6 (current) and no LoadReader or TreeFromMap exists
Grepped the source for pelletier/go-toml v1.9.5 (last v1 version) and both functions exist in source code.

koanf/go.mod

Line 21 in 38c5fe1

github.com/pelletier/go-toml v1.7.0

koanf uses toml v1.7.0. Installing koanf with go get -u github.com/knadh/koanf thus pulls v1.7.0, which works.

With major version changes, the package name is suffixed with v$n, which is treated as a different module altogether. https://github.com/pelletier/go-toml/blob/090cccf4bac30af63f82eaf7225077b47c85f8e9/go.mod#L1

Thanks for the response knadh. Will do that instead.